I use Backbone.js as a frame, and in my opinion I have several small images (garbage can delete, icon, etc.). And when the view re-displays these images.
I solved this with large images, creating a new view of everything that I do not want to use - and without causing them to be rendered. But I was wondering if there is another way to do this without breaking my mind into a bunch of pieces?
This is the general format in which I view my views:
window.SomeView = Backbone.View.extend({ initialize: function() { this.model.bind('change', this.render, this); this.template = _.template($('#view-template').html()); }, render: function(){ var renderedContent = this.template(this.model.toJSON()); $(this.el).html(renderedContent); return this; }, events: { 'click .delete' : delete }, delete: function(ev){
And then I attach them to the div by:
var newView = new PopupItemImgView({model: someModel}); $('#styleimage').append(newView.render().el);
My template might look like
<script type="text/template" id="view-template"> <% print('Content content - <img src="images/delete.gif" class="delete">'); %> </script>
source share