Jquery 渲染后附加div clear元素
Js问题无法附加清除div 我所做的每一件事都希望在我的项目之前附加div clear 像 名单 清楚的 项目 项目 项目 这是我的密码Jquery 渲染后附加div clear元素,jquery,backbone.js,marionette,Jquery,Backbone.js,Marionette,Js问题无法附加清除div 我所做的每一件事都希望在我的项目之前附加div clear 像 名单 清楚的 项目 项目 项目 这是我的密码 var MyItemView = Backbone.Marionette.ItemView.extend({ template: tplI , className: 'item', tagName : 'article', }); var myCompositeView = Backbone.Mari
var MyItemView = Backbone.Marionette.ItemView.extend({
template: tplI ,
className: 'item',
tagName : 'article',
});
var myCompositeView = Backbone.Marionette.CompositeView.extend({
itemView: MyItemView ,
itemViewContainer: "#list",
template: tplC ,
className : 'wikis' ,
initialize: function () {
this.collection = new Collection () ;
this.model = new CollectionModel() ;
this.listenTo(this.collection, "reset", this.set);
},
set: function ( collect ) {
this.model.set( collect.wiki ) ;
this.render() ;
} ,
onRender : function( evt ){
if ( $.trim( this.$('#list').html() ) != "" ) {
this.$('#list').append( '<div class="clear"></div>' ) ;
}
},
onClose :function() { $('#list').
this.$el.height( 0 ) ;
}
});
var MyItemView=Backbone.marionete.ItemView.extend({
模板:tplI,
类名:“项”,
标记名:“article”,
});
var myCompositeView=Backbone.marionete.CompositeView.extend({
itemView:MyItemView,
itemViewContainer:#列表“,
模板:tplC,
类名:“Wiki”,
初始化:函数(){
this.collection=新集合();
this.model=新集合模型();
this.listenTo(this.collection,“reset”,this.set);
},
设置:功能(收集){
this.model.set(collect.wiki);
这个。render();
} ,
onRender:函数(evt){
if($.trim(this.$('#list').html())!=“”){
此.$('#列表')。附加('');
}
},
onClose:function(){$('#list')。
此高度为$el.height(0);
}
});
感谢您的帮助找到临时解决方案
在线1566
// Internal method to loop through each item in the
// collection view and show it
showCollection: function(){
var ItemView;
this.collection.each(function(item, index){
ItemView = this.getItemView(item);
this.addItemView(item, ItemView, index);
}, this);
this.triggerMethod("renderCollection", this);
},
然后
在集合视图中
initialize: function () {
//console.log( 'collectionView' ) ;
this.on( 'renderCollection' , this.collectionrendered ) ;
},
collectionrendered: function(){
this.$el.find( this. itemViewContainer ).append( '<div class="clear"></div>' ) ;
console.log('collectionrendered') ;
}
初始化:函数(){
//log('collectionView');
this.on('renderCollection',this.collectionrendered);
},
collectionrendered:函数(){
this.el.find(this.itemViewContainer).append(“”);
console.log('collectionrendered');
}