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

php - regexp cyrillic filename not matches -

c# - OpenXML hanging while writing elements -

sql - Select Query has unexpected multiple records (MS Access) -