javascript - Backbone underscore lamba or conditional branching? -
very new backbone , js , have following statement created branch on logic:
if (config.version !== 'undefined') { mgr.useviews().setviews({}); /** hide div1 view layout **/ } else { mgr.useviews().setviews({ /** show div1 view layout **/ '#div1': new div1view({ model: mydiv1model }) }); }
what more effective way use lambda or construct within setviews() method instead of wrapping entirely if statement?
something like:
mgr.useviews().setviews({ /** if (config.version === 'undefined') {**/ <= not sure be? '#div1': new div1view({ model: mydiv1model }) /** } **/ });
you need conditional expression
var views = (config.version !== 'undefined') ? {} : { '#div1': new div1view({ model: mydiv1model }) }; mgr.useviews().setviews(views);
related: sure want check string 'undefined'
?
Comments
Post a Comment