0

I want to use Javascript Module Pattern with Knockout JS and Pager JS, i know how to use Javascript Module Pattern and Knockout JS and Pager JS Separately but i don't know how to integrate them.Here is my code of Javascript Module Pattern

var Module = (function(){
    var my = {};

    my.testMethod = function(){
        alert("test method is called");
    };
    return my;
}());

(function(anyobj){

    anyobj.anotherMethod = function(){
        alert("another Method is called");
    };

    anyobj.testMethod();

}(Module));

now this code work find but i don't know how to integrate the above code with the given below code in order to make knockout js and pager js work fine with Javascript Module Pattern

var moduleViewModel = new Module();
pager.extendWithPage(moduleViewModel);
ko.applyBindings(moduleViewModel);
pager.start();
4

1 回答 1

1

用这个更新以下代码,这应该可以工作

var Module = (function(){
    var my = {};

    my.testMethod = function(){
        alert("test method is called");
    };
    return my;
}());

(function(anyobj){

    anyobj.anotherMethod = function(){
        alert("another Method is called");
    };

    anyobj.testMethod();

}(Module));

//---  Module is an Object so we can pass it to a function as an argument  ---//
 pager.extendWithPage(Module);
 ko.applyBindings(Module);
 pager.start();
于 2015-09-16T08:41:55.983 回答