函数定义中的TypeError

时间:2014-12-30 10:45:44

标签: jquery knockout.js dotnetnuke

在定义我的函数时,我的javascript代码中出现了一个Typeerror:

TypeError: (intermediate value)(...) is not a function

该功能定义为:

;(function (factory) {
    if (typeof define === "function" && define.amd) {
        define(["knockout", "jquery", "jquery.ui.sortable"], factory);
    } else {
        factory(window.ko, jQuery);
    }
})(function (ko, $) {

    // Some code including a bindingHandlers... 

})();

这个代码包含在我的.ascx(view)中,在淘汰赛中包括:

错误是什么意思,如何追踪并修复错误?

我像这样介绍(并绑定)我的viewModel:

<script type="text/javascript">
    jQuery(document).ready(function ($) { 
    var client = new myServiceClient(<%:ModuleContext.ModuleId%>);
    client.getModel()
        .done(function (model) {
            var viewModel = new ViewModel(model, client);
            //$("#template-load").load("DesktopModules/BBWysSceneStacker/scene-template.html")
             //   .success(
                    ko.applyBindings(viewModel, document.getElementById("<%= BBWysSceneStacker.ClientID %>"))
             //   )
            ;
        })
        .fail(function (model) {
            alert("Error in getModel!");
        });
    });
</script> 

1 个答案:

答案 0 :(得分:0)

无需第二次运行功能。

&#13;
&#13;
;(function (factory) {
    if (typeof define === "function" && define.amd) {
        define(["knockout", "jquery", "jquery.ui.sortable"], factory);
    } else {
        factory(window.ko, jQuery);
    }
})(function (ko, $) {
    console.log('factory working');
});
&#13;
&#13;
&#13;