Javascript Backbone.js Pinterest模式
我正在使用backbone.js构建我的前端。 所以我想做的是,在“lightbox”(与pinterest相同)中渲染视图。 我这样试过:Javascript Backbone.js Pinterest模式,javascript,jquery,backbone.js,pinterest,Javascript,Jquery,Backbone.js,Pinterest,我正在使用backbone.js构建我的前端。 所以我想做的是,在“lightbox”(与pinterest相同)中渲染视图。 我这样试过: var itemDetailsBoxView = CloseableView.extend({ el: '#itemwrapperItemBox #itemwrapperItem2', initialize: function(options) { var self = this; self.render(options); }, rend
var itemDetailsBoxView = CloseableView.extend({
el: '#itemwrapperItemBox #itemwrapperItem2',
initialize: function(options) {
var self = this;
self.render(options);
},
render: function(options) {
$('#itemwrapperItemBox').fadeIn(300);
var self = this;
app._itemDetailsView = new itemDetailsView({id: options.id, el: '#itemwrapperItemBox #itemwrapperItem2'});
self.rendered(app._itemDetailsView);
},
events: {
'keydown': 'keydownHandler'
},
keydownHandler: function(e) {
switch (e.which) {
// esc
case 27 :
$('#itemwrapperItemBox').hide();
break;
}
}
此视图仅在灯箱中打开另一个视图(itemDetailsView)。单击某个项目时,会打开此ItemDetailsBox视图:
itemDetails: function(events) {
var self = this;
var that = $(events.currentTarget).parents('.item');
var id = that.find('.covercontainer').find('img').data('id');
if (app._itemDetailsBox) {
app._itemDetailsBox.close();
}
app._itemDetailsBox = new itemDetailsBoxView({id: id});
self.rendered(app._itemDetailsBox);
app.navigate("/collage/" + id, false);
},
然而,这种方法存在几个问题: