我使用单页应用程序,在3页中创建3个Gridstack。
如果我一页一页地打开,则调整小部件大小的速度对于每一页来说都会变慢。
但是,如果我重新加载页面就可以了。
我使用Backbone的Router打开每个页面(而不是重新加载页面)。
这是我的代码:
Grid-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);
}
})
LayoutSetting.js
return Backbone.Marionette.LayoutView.extend({
template: "template",
onShow: function() {
createGridStack($(".grid-stack"));
this.gridStack = $(gridStackEl).data('gridstack');
}
})
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句