gpt4 book ai didi

javascript - 如何在创建新网格之前销毁网格堆栈?

转载 作者:行者123 更新时间:2023-12-03 10:26:58 25 4
gpt4 key购买 nike

我使用单页应用程序,我在 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');
}
})

最佳答案

尝试

this.gridStack.removeAll();

destroy()

查看文档 here

关于javascript - 如何在创建新网格之前销毁网格堆栈?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29359353/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com