Sha256: 2d078ab49bf091ea8ccf7a06d5db7825ae6015701184d603d2281c3f649c5fe1
Contents?: true
Size: 1.6 KB
Versions: 4
Compression:
Stored size: 1.6 KB
Contents
exoskeleton.views.base_view = Backbone.View.extend({ remove: function(){ if (_.isFunction(this.clean_up)){ this.clean_up() } _.each(this.child_views, function(child_view){ child_view.remove() }) this.child_views = [] this.$el.children().remove() this.undelegateEvents() Backbone.View.prototype.remove.call(this); }, add_subview: function(view_to_append){ if (_.isUndefined(this.child_views)) { this.child_views = [] } this.child_views.push(view_to_append) }, append_view: function(view, target){ this.$(target).append(view.render().el) this.add_subview(view) }, set_html: function(view, target){ this.$(target).html(view.render().el) this.add_subview(view) }, /*postAttachment This function executes the supplied function after the view has been attached to the DOM. If the view is already attached to the DOM the function is executed immediately. If the view is not attached to the DOM, it will check every eighth second for up to 30 seconds and execute the function as soon as it is attached. If the view is not attached to the DOM within 30 seconds, the function will never be executed. The view itself will be passed into the function as an argument. */ post_attachment: function(fn, count){ if ( count ){ count++ } else { count = 0 } if( count > 240 ){ return } if( $(this.el).parents('body').length > 0 ){ fn(this) } else { var _this = this setTimeout(function(){ _this.post_attachment(fn, count) }, 125) } } })
Version data entries
4 entries across 4 versions & 1 rubygems