我使用单页应用程序,我在 3 个页面中创建 3 个 Gridstack。
如果我一页一页地打开,调整小部件大小的速度会变慢。
但是,如果我重新加载页面,它就可以正常工作。
我使用 Backbone 的路由器打开每个页面(不是重新加载页面)。
这是我的代码:
网格-satck.js
createGridStack: function(gridEl) {
var options= {
animate: true,
width: 12,
cell_height: 50,
resizable: {
handles: "e, se, s, sw, w"
}
};
$(gridEl).gridstack(options);
}
模板:div class='grid-stack'/>
HomePageLayout.js
return Backbone.Marionette.LayoutView.extend({
template: "template",
onShow: function() {
createGridStack($(".grid-stack"));
this.gridStack = $(gridStackEl).data('gridstack');
this.gridStack.movable('.grid-stack-item', false);
this.gridStack.resizable('.grid-stack-item', false);
}
})
ClientLayout.js
return Backbone.Marionette.LayoutView.extend({
template: template,
onShow: function() {
createGridStack($(".grid-stack"));
this.gridStack = $(gridStackEl).data('gridstack');
this.gridStack.movable('.grid-stack-item', false);
this.gridStack.resizable('.grid-stack-item', false);
}
})
布局设置.js
return Backbone.Marionette.LayoutView.extend({
template: "template",
onShow: function() {
createGridStack($(".grid-stack"));
this.gridStack = $(gridStackEl).data('gridstack');
}
})
最佳答案
关于javascript - 如何在创建新网格之前销毁网格堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29359353/