我使用 Gridster 在我的应用程序中渲染图 block 布局,并使用 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。
为什么?
最佳答案
看来您可能使用了源文件,而不是 gridster 的编译版本。你是从GitHub下载的吗?使用 dist/jquery.gridster.min.js
,而不是 src/jquery.gridster.js
供以后引用,src/
中的版本供Grunt编译时使用.
关于javascript - Gridster 没有出现在 jQuery 变量下,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26615158/