我有一个创建表单来创建一个对象.如果选中了复选框并且标记为必需(通过模型中的属性),则创建模型具有一些仅可见的属性(.hide,.show()).
不幸的是,如果未选中该复选框,则会对隐藏的属性执行所需的验证.
如何禁用此属性所需的验证?
我尝试将input元素的data-val属性设置为false,但这不起作用.
有点想法吗?
在此先感谢Tobias
更新:
这是java脚本代码.data-val属性设置为false.似乎验证不关心这个属性.还有data-val-required属性,但有一个我无法备份的文本.
$(function () {
$("#MyCheckbox")
.change(function () {
if (this.checked) {
$("#divWithChildProperties [data-val]").attr("data-val", true);
$("#divWithChildProperties ").show();
}
else {
$("#divWithChildProperties [data-val]").attr("data-val", false);
$("#divWithChildProperties ").hide();
}
})
});
Run Code Online (Sandbox Code Playgroud) 基本上我需要能够做到这一点:
var obj = {"foo":"bar"},
arr = [];
with( obj ){
arr.push( foo );
arr.push( notDefinedOnObj ); // fails with 'ReferenceError: notDefinedOnObj is not defined'
}
console.log(arr); // ["bar", ""] <- this is what it should be.
Run Code Online (Sandbox Code Playgroud)
我正在寻找一个"全局"等价的{}.__defineGetter__ 或者{get},以便为所有未定义的属性getter返回一个空字符串(请注意,这与一个属性不同undefined).
是否有任何方法可以在Backbone.Controller中检测无效(或未定义)路由并触发404页面?
我已经在我的控制器中定义了这样的路由,但它没有用.
class MyController extends Backbone.Controller
routes:
"method_a": "methodA"
"method_b": "methodB"
"*undefined": "show404Error"
# when access to /#method_a
methodA: ->
console.log "this page exists"
# when access to /#method_b
methodB: ->
console.log "this also exists"
# when access to /#some_invalid_hash_fragment_for_malicious_attack
show404Error: ->
console.log "sorry, this page does not exist"
Run Code Online (Sandbox Code Playgroud)
我使用Backbone.Controller的构造函数来匹配当前的哈希片段和@routes.
class MyController extends Backbone.Controller
constructor: ->
super()
hash = window.location.hash.replace '#', ''
if hash
for k, v of @routes
if k is hash
return
@show404Error()
routes:
"method_a": "methodA"
"method_b": …Run Code Online (Sandbox Code Playgroud) 我不能,为了我的生活,弄清楚如何在下面的屏幕截图中更改灰色突出显示颜色,使文本更容易辨认.有谁知道我需要更改"显示项目"名称是什么?
要进入"主题编辑器",请选择工具 => 选项 => 环境 => 字体和颜色.我找不到要编辑的内容.
我还查看了Tools => Options => Text Editor => HTML => Formatting无效.
替代文字http://i41.tinypic.com/sbop4n.png
如果您想知道主题是略微修改的编码本能主题
下面的代码用于查找可以通过javascript滚动(body或html)的元素.
var scrollElement = (function (tags) {
var el, $el, init;
// iterate through the tags...
while (el = tags.pop()) {
$el = $(el);
// if the scrollTop value is already > 0 then this element will work
if ( $el.scrollTop() > 0){
return $el;
}
// if scrollTop is 0 try to scroll.
else if($el.scrollTop( 1 ).scrollTop() > 0) {
// if that worked reset the scroll top and return the element
return $el.scrollTop(0);
}
}
return $();
} …Run Code Online (Sandbox Code Playgroud) The new JavaScript engine takes advantage of multiple CPU cores through Windows to interpret, compile, and run code in parallel.- http://technet.microsoft.com/en-us/library/gg699435.aspx
和
The Chakra engine interprets, compiles, and executes code in parallel and takes advantage of multiple CPU cores, when available.- http://msdn.microsoft.com/en-us/ie/ff468705.aspx
等等,什么?!?这是否意味着我们在IE9中有多线程并行JavaScript代码执行(在web-workers之外)?
我认为这只是一个糟糕的营销噱头,但我想看到更多关于此的信息.也许他们的意思是不同的浏览器窗口/标签/进程可以使用多个CPU?
我正在编写一个常量字符串比较函数(对于node.js),并且想要为这个函数禁用V8的优化编译器; 使用命令行标志是不可能的.
我知道,使用with{}(或try/catch语句)块将禁用优化编译器现在,但恐怕这个"功能"(错误)将被固定在未来的版本.
是否存在禁用V8优化编译器的不可变(和记录)方式?
功能示例:
function constantTimeStringCompare( a, b ) {
// By adding a `with` block here, we disable v8's optimizing compiler.
// Using Object.create(null) ensures we don't have any object prototype properties getting in our way.our way.
with ( Object.create( null ) ){
var valid = true,
length = Math.max( a.length, b.length );
while ( length-- ) {
valid &= a.charCodeAt( length ) === b.charCodeAt( length );
}
// returns true if valid == …Run Code Online (Sandbox Code Playgroud) 如何实现跨浏览器不透明度渐变(不是颜色渐变)?请参阅以下代码:
<div style="background-color:Red;display:block;height:500px;width:500px;filter:alpha(Opacity=100, FinishOpacity=0, Style=1, StartX=0, StartY=0, FinishX=0, FinishY=500)"></div>
Run Code Online (Sandbox Code Playgroud)
它在IE中运行良好,但在其他浏览器中没有,如firefox,safari ..等.什么是firefox的等效语法?请不要建议我使用渐变图像.
该假想情景:
联盟会员通过向客户销售商品/服务/小部件来在我的网站上赚钱.您可以将其视为一个简单的联盟计划.这笔钱存储在一个帐户中,直到会员请求他们的钱.
关联公司不想等待支票来邮件; 他们想登录他们的管理部门(在我的网站上),然后点击神奇的"转移我的硬挣钱现在!傻瓜"按钮,并将他们的数百万美元直接存入他们的银行账户(此转账可能需要"3-4天"如果必须---联盟会员只是想让他们觉得他们总能控制自己的钱".
现在,PayPal已经做了"现在发送我的挣钱!傻瓜." 功能很好.他们的API甚至允许从一个Paypal账户转账到另一个账户; 它只是不允许存款到银行账户.联盟会员很懒,不想登录他们的Paypal账户来转账.
那么,开发人员可以做些什么呢?
.
// affiliate and crdentials are pulled from my database.
Affiliate affiliate = db.Affiliates.GetByID(123456);
Credentials creds = affiliate.GetBankCredentials();
// paymentAPI is, well, its an API.
Xml response = paymentAPI.InitiateMoneyTransfer({from: myAccountCrdentials, to: creds, amount: 123, currency: "USD"});
if(response.success){
print "Bling Bling! Transfer initiated";
}
else{
print response.msg;
}
Run Code Online (Sandbox Code Playgroud)
ps我在美国
c# language-agnostic currency payment-gateway payment-processing
javascript ×7
node.js ×2
backbone.js ×1
c# ×1
chakra ×1
coffeescript ×1
css ×1
currency ×1
highcharts ×1
html ×1
jquery ×1
opacity ×1
scroll ×1
v8 ×1
validation ×1