backbone.js - Javascript Dynamic object properties through functions returning strings -


i'm building backbone marionette application. in marionette can like:

marionette.application.extend({     regions: {         mainregion: function(){return somecondition?"#a":"#b"},         otherregion: "#something"     } }) 

i'm trying implement in application custom objects. best way achieve this? currently, i'm checking every value:

if(typeof obj == "function") {     this.data.obj = obj(); } else {     this.data.obj = obj; } 

or corresponding ?: expression. there easier way this?

underscore has result method want (see http://underscorejs.org/#result)

you can find implementation here: http://underscorejs.org/docs/underscore.html#section-128


Comments

Popular posts from this blog

html - Sizing a high-res image (~8MB) to display entirely in a small div (circular, diameter 100px) -

java - IntelliJ - No such instance method -

identifier - Is it possible for an html5 document to have two ids? -