我收到此错误并且很难纠正它。我收到以下错误消息:callback.call 不是函数
我在下面发布了代码片段以供评论,似乎是在调用 validateCheckBox(o) 时触发了错误。我知道该错误是由脱离上下文的函数触发的,但不确定如何修复。
function checkLength( o, n, min, max ) {
console.log( arguments.length );
if ( arguments.length < 4 ) {
// issue here with callback.call is not a function
if ( validateCheckBox(o) ){
validateCheckBox(o);
}
}else {
if ( o.val().length > max || o.val().length < min ) {
o.addClass( "ui-state-error" );
updateTips( "Length of " + n + " must be between " +
min + " and " + max + "." );
return false;
} else {
return true;
}
}
}
function validateCheckBox( o ) {
var css = $(".border").css({
"border-color": "",
"border-weight": "",
"border-style" : "",
"background-color": "",
"background-image": "",
"background-repeat":"",
"background-position":""
});
//console.log(css);
var invalidChkBox = {
"border-color":"#cd0a0a",
"border-weight":"1px",
"border-style":"solid",
"background-color": "#feflec",
"background-image": "url('lib/jquery-ui/css/images/ui-bg_glass_95_fef1ec_1x400.png')",
"background-repeat": "repeat-x",
"background-position": "50% 50%"
}
// throwing error callback is not defined
var isChecked = $( "#verification" ).is(":checked");
if ( isChecked == false || isChecked == undefined ) {
$( ".border" ).css( invalidChkBox );
o.addClass( "ui-state-error" );
$( ".validateTips" ).text( "You must agree that all information is accurate and true, by checking the box." );
}else{
// reported bug callback.call is not a function @error below
$( ".validateTips" ).css( 'display', null ).text( "" );
$( ".border" ).css( css );
}
}
valid = valid && checkLength ( verification, "Verification", 1 );
提前致谢。
最佳答案
感谢您的帮助。事实证明这是一件简单的事情。我试图将 css 规则分配给已定义规则的类...
var css = $(".border").css({
"border-color": "",
"border-weight": "",
"border-style" : "",
"background-color": "",
"background-image": "",
"background-repeat":"",
"background-position":""
});
$( ".border" ).css( css ); --> line throwing error....
关于javascript - callback.call 不是一个函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32126763/