【发布时间】:2014-10-28 17:53:34
【问题描述】:
我正在使用 Gridster 在我的应用程序中呈现图块布局,使用 NodeBB 作为基础。
代码如下:
<script src="/jquery.js"></script>
<script src="/gridster.js"></script>
<script>
$.noConflict();
jQuery(function () {
jQuery(".gridster ul").gridster({
widget_margins: [10, 10],
widget_base_dimensions: [175, 175],
serialize_params: function(wi, wgd) {
console.log($(wi).attr('id'));
return {
id: $(wi).attr('id'),
col: wgd.col,
row: wgd.row,
size_x: wgd.size_x,
size_y: wgd.size_y
};
},
draggable: {
start: function () {
dragged = 1;
},
stop: function () {
setTimeout(function () {
dragged = 0;
}, 5);
}
}
});
});
</script>
如您所见,我尝试在 <script> 标记中初始化 Gridster,但是当我运行它时,我得到:
Uncaught TypeError: undefined is not a function
尝试访问 gridster ($('.gridster ul').gridster( \\ ..) 时。 jQuery 很好,它只是 Gridster。
为什么?
【问题讨论】:
-
是的。在 Chrome 开发者工具中,它显示脚本已加载。
标签: javascript jquery gridster