Skip to content
This repository has been archived by the owner on Jun 19, 2020. It is now read-only.

Commit

Permalink
Move the update method from UIItem down to View.
Browse files Browse the repository at this point in the history
  • Loading branch information
Clément Vollet committed Sep 20, 2013
1 parent 8c20ca5 commit f4b9d75
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 19 deletions.
19 changes: 0 additions & 19 deletions lib/ui/item.js
Expand Up @@ -126,25 +126,6 @@ define([
},


/**
* Updates the contents of the view when the model changes
*
* Default implementation re-renders the view whenever a change is detected,
* unless the view has not yet been rendered.
*
* Classes that derive this class may want to override that function to
* provide a smarter mechanism, in particular not to update the underlying
* view if it does not need to be updated.
*
* @function
*/
update: function () {
logger.log(this.logid, 'update');
if (!this.rendered) return;
this.render();
},


/**
* Generates the view's HTML content for the underlying model.
*
Expand Down
29 changes: 29 additions & 0 deletions lib/view.js
Expand Up @@ -233,6 +233,7 @@ define([
this.onScrollHandler = _.bind(this.onScrollHandler, this);
},


/**
* Renders the view.
*
Expand All @@ -258,6 +259,7 @@ define([
}, this));
},


/**
* Sets the HTML content of the view to the DOM element associated with the
* view.
Expand Down Expand Up @@ -292,6 +294,7 @@ define([
this.rendered = true;
},


/**
* Generates the view's HTML content for the underlying model.
*
Expand Down Expand Up @@ -402,6 +405,7 @@ define([
return outerHTML;
},


/**
* Hides the view's DOM element
*
Expand All @@ -419,6 +423,7 @@ define([
this.trigger('hide');
},


/**
* Shows the view's DOM element
*
Expand Down Expand Up @@ -501,6 +506,7 @@ define([
}, this));
},


/**
* Enhances the view with additional logic.
*
Expand Down Expand Up @@ -541,6 +547,7 @@ define([
}
},


/**
* Change the view's element ("this.el" property), including event
* re-delegation.
Expand Down Expand Up @@ -569,6 +576,26 @@ define([
return this;
},


/**
* Updates the contents of the view when the model changes
*
* Default implementation re-renders the view whenever a change is detected,
* unless the view has not yet been rendered.
*
* Classes that derive this class may want to override that function to
* provide a smarter mechanism, in particular not to update the underlying
* view if it does not need to be updated.
*
* @function
*/
update: function () {
logger.log(this.logid, 'update');
if (!this.rendered) return;
this.render();
},


/**
* Overrides default "remove" function for logging purpose
*
Expand All @@ -581,6 +608,7 @@ define([
Backbone.View.prototype.remove.call(this);
},


/**
* Returns a callback function that only gets called provided
* the view has not yet been removed.
Expand Down Expand Up @@ -608,6 +636,7 @@ define([
this.onScroll.call(el[0], e, el[0].scrollHeight, el.scrollTop(), el.scrollLeft());
},


/**
* The scrollTo function tries its best to scroll where you want.
*/
Expand Down

0 comments on commit f4b9d75

Please sign in to comment.