javascript - Backbone: Best way to handle variable common to all models -
i'm developing first backbone single page app project , i'm facing issue. basically have menu (html select input element) implemented view. value used control pretty every other data requests since specifies kind of data show in other views. right handle dom event , trigger global event every model can catch , keep track internally of new value. that's because value needed when requesting new data. doesn't solution because a) end writing same function (event handler) in every model , b) several models same variable. var metrics = backbone.collection.extend({ url: "dummy-metrics.json", model: metricsitem, initialize: function () { this.metric = undefined; }, setmetric: function (metric) { this.metric = metric; globalevents.trigger("metric:change", this.get(metric)); } }); var globalcomplexity = backbone.collection.extend({ url: function () { var url = "http://asd/global.jso...