0

Marionette.Js 问题无法附加清晰的 div

我所做的每一件事我都需要在我的项目之前添加 div clear

喜欢

列出清除项目项目项目

这是我的代码

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 ) ; 
        }
    }); 

谢谢你的帮助

4

1 回答 1

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') ;
    }
于 2013-09-16T04:50:58.810 回答