Created
March 29, 2018 07:57
-
-
Save dmy3k/0ac4506b427a5b4a0ab3d57e0cf632b1 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Renders part of the view instead all of it. | |
* Useful in sutuations where view contains counter and input fields. | |
* Counter needs to be updated, while input state left intact. | |
* */ | |
Backbone.View.prototype.renderPartial = function(selector, data, template) { | |
template = template || this.template; | |
var self = this; | |
var $html = $('<div>' + template(data) + '</div>'); | |
selector.split(',').forEach(function(q) { | |
q = q.trim(); | |
self.$(q).replaceWith($html.find(q)); | |
}); | |
return this; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment