javascript - Right way for backbone view code -


i have side view list , when 1 of item in list clicked show corresponding view

my code follows:

view

app.view.brandsidepanelview = backbone.view.extend({       tagname: 'div',       template: _.template($('#brand-side-panel').html()),       template_brand: _.template($('#brand-create').html()),       template_offer: _.template($('#offer-create').html()),        initialize: function() {           this.render();       },        events: {           'click .bra-main': 'showbrandcreateview',           'click .bra-off': 'showoffercreate',           'click .bra-cmgn': 'showcampaigncreate'       },        showbrandcreateview: function(e) {           e.preventdefault();           this.reset();           $('.crt-cnt').html(this.template_brand());       },        showoffercreate: function(e){           e.preventdefault();           this.reset();           $('.crt-cnt').html(this.template_offer());       },         render: function() {           $('.crt-cnt').html(this.template_brand());           var $el = $(this.el);           $el.html(this.template());           return $(this.el);       },        reset: function(){           $('.crt-cnt').empty();       } }); 

html

<div class="list-group">     <div class="list-group-item bra-main"><i class="fa fa-angle-double-right"></i>&nbsp;<fmt:message key="brand" /></div>     <div class="list-group-item bra-off"><i class="fa fa-angle-double-right"></i>&nbsp;<fmt:message key="brand.offer" /></div>     <div class="list-group-item bra-cmgn"><i class="fa fa-angle-double-right"></i>&nbsp;<fmt:message key="brand.campaign" /></div> </div> 

everything here static. nothing fetched server. new backbone. current code works wants know if doing right way.

if side view list won't change in time, it's ok this, it's sort of static menu.

but if elements in list change, must wrap in view , fetch elements server


Comments

Popular posts from this blog

Android layout hidden on keyboard show -

google app engine - 403 Forbidden POST - Flask WTForms -

c - Why would PK11_GenerateRandom() return an error -8023? -