I'm having an architecture difficulty with application designed in Backbone.
I've got cascaded, hierarchical views, i.e. root view has header, middle and footer views. Each of them consists of some lower level views, e.g. header view consists of tabs, preferences and login/logout views. It's just a view aggregation.
I also have a configuration model, which has several attributes, it's loaded via AJAX (standard backbone fetch). The model attributes are displayed in the interface using popups, menus etc. to enable the user to choose his settings. When the user changes a setting, possibly many parts of the app will have to re-render. The configuration model holds "state" properties (e.g. property currentPeriod
is used among periods
which were fetched via AJAX)
Inside views, I use listenTo(this.model, 'change:currentPeriod', this.render)
to make this view re-render when anything is changed in the configuration.
I set all my default state attributes inside model::parse
. The problem is that if I have 10 attributes to set (after parse is over) and probably each of them will trigger some events, many of them will be run multiple times (which is not what I want).
I was looking for a possibility to set current state attributes inside parse with the {silent:true} option - then no events would be triggered. I hope some of you already had the same problem and there exists an easy solution. Thanks in advance!
{silent:true}
when you callset
, to prevent change events; isn't that what you want? – freejoshparse
function which returned value is beingset
after the parse function is over. Or if there is a better solution, I'd appreciate it. – ducin