【问题标题】:Gridster not appearing under jQuery variableGridster 没有出现在 jQuery 变量下
【发布时间】: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>

如您所见,我尝试在 &lt;script&gt; 标记中初始化 Gridster,但是当我运行它时,我得到:

Uncaught TypeError: undefined is not a function

尝试访问 gridster ($('.gridster ul').gridster( \\ ..) 时。 jQuery 很好,它只是 Gridster。

为什么?

【问题讨论】:

  • 是的。在 Chrome 开发者工具中,它显示脚本已加载。

标签: javascript jquery gridster


【解决方案1】:

看起来您可能使用了源文件,而不是 gridster 的编译版本。你是从 GitHub 下载的吗?使用dist/jquery.gridster.min.js,而不是src/jquery.gridster.js

src/中的版本供Grunt编译时使用。

【讨论】:

  • 我使用的文件是开发者编译和缩小的版本(gridster.min.js),它在放入NodeBB之前工作。还是谢谢你!
  • 那么你是想通了还是还是不行?
  • 我转而使用 NodeBB 内置系统来管理网格。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多