javascript - callback.call 不是一个函数

标签 javascript jquery jquery-ui

我收到此错误并且很难纠正它。我收到以下错误消息: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/

相关文章:

javascript - 如何在其中保留 div 的文本,如果更大,则 div 向下扩展?

java - 如何使用 Angular 方法将数据检索到 selenium java 脚本中

javascript - 将数组添加到 Jquery 中的 css 'content'

javascript - 有没有办法让 jQuery UI slider 从顶部而不是底部的 0 开始?

javascript - 为什么斜杠字符会导致我的选择器失败?

javascript - 模型上的 Backbone 集合更改事件

javascript - 扩展主干模型或 View 时,我如何创建在实例而不是原型(prototype)上创建的属性?

javascript - 如何将 id 转换为小写?

javascript - 居中动画 Div

javascript - 禁止嵌套排序混合