我試過使用js文件在網頁中包含分頁,但它在瀏覽器控制檯中顯示TypeError: $(...).pagination is not a function
可能的問題是什麼? 注意:我正在使用require.js來加載腳本。 請重播,由於事先 這是我需要命名爲testPagination.jsUncaught TypeError:undefined不是simplePagination.js中的函數
define(['jquery','pagination'], function($,pagination) {
/* GET DATASOURCE FROM HIDDEN FIELD */
function Hello() {
alert('helo...!!!');
}
function loadPagination(total)
{
alert("PAGINATION CALLED");
$('#listing-paginationtest').pagination({
items : total,
itemsOnPage : 10,
cssStyle : 'dark-theme',
onPageClick : function(pageNumber) {
}
});
alert("PAGINATION END");
}
return {
Hello:Hello,
loadPagination:loadPagination
};
});
模塊和我打電話main.js這樣該模塊方法
require.config({
baseUrl : "js",
paths : {
"text" : "libs/require/plugins/text",
"jquery" : "libs/jquery/jquery",
"blockUI" : "libs/jquery/plugins/jquery.blockUI",
"pagination" : "libs/jquery/plugins/jquery.simplePagination",
"cookie" : "libs/jquery/plugins/jquery.cookie",
"backbone" : "libs/backbone/backbone",
"underscore" : "libs/underscore/underscore",
// BACKBONE MODELS
"models" : "models/models",
"templates" : "../templates",
"plugins" : "libs/jquery/plugins",
"pages" : "pages",
"util" : "modules/store/util",
"store" : "modules/store/main",
// MODULES
"datasourceModule" : "modules/datasourceModule",
"cookieModule" : "modules/cookieModule",
"testPagination":"modules/testPagination"
"bootstrap" : "../design/js/bootstrap.min",
},
waitSeconds: 200,
shim : {
'jquery' : {
exports : '$'
},
'backbone' : {
deps : [ 'underscore', 'jquery' ],
exports : 'Backbone'
},
'underscore' : {
exports : '_'
},
'models' : {
deps : [ 'backbone' ],
},
'datasourceModule' : {
deps : [ 'jquery', 'backbone', 'models' ]
},
'store' : {
deps : [ 'backbone' ],
},
'testPagination' : {
deps : [ 'jquery' ]
},
// DESIGN
'bootstrap' : {
deps : [ 'jquery' ]
},
}
});
function loadPageNumbers() {
alert("Hi hi");
require([ "jquery", "testPaginationModule"],
function($, testPaginationModule) {
testPaginationModule.loadPagination(1000);
});
}
我們怎麼可能調試我們看不到的代碼? – Cerbrus 2014-11-21 09:34:47
我也在這裏給出了代碼... – Juhan 2014-11-21 09:43:10
在調用這個函數時是否存在'#listing-paginationtest'? – 2014-11-21 11:38:35