You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Mar 20, 2021. It is now read-only.
In our project we have views that uses more than one model, because some models contains state that are shared across the application.
It would be convenient to gain access to dataObject(), so that we can implement behaviour for these custom model attributes that mimics those of the standard "model" and "collection" attributes.
An example of how this could work:
SomeView=Thorax.View.extend({events: {model: {sync: function(){console.log('model synced')}}sharedState: {'change:someSharedData': function(){console.log('sharedState changed someSharedData')}}}})Thorax.dataObject('sharedState',{set: 'setSharedState'})sharedState=newThorax.Model({someSharedData: 3})newSomeView({sharedState: sharedState})sharedState.set('someSharedData',4)// prints out "sharedState changed someSharedData"
Or do you have another suggestion on how to approach this?
The text was updated successfully, but these errors were encountered:
I'm not certain that I interperet your question right, but the desire is, since we often use multiple models/collections per view, to bind events to all models/collections in the same manner.
And I like the idea of using the events-hash. A quick glance on the events-hash gives you a fair idea of what happens during the lifecycle of a view.
To be able to assign dataObjects per view (in contrast to all views, as dataObject() does currently) would also be more clean IMO if you choose to pursue this route.
What's your thoughts?
kpdecker
changed the title
Gain access to dataObject()
Allow events hash definitions on arbitrary view data objects
Nov 30, 2014
In our project we have views that uses more than one model, because some models contains state that are shared across the application.
It would be convenient to gain access to dataObject(), so that we can implement behaviour for these custom model attributes that mimics those of the standard "model" and "collection" attributes.
An example of how this could work:
Or do you have another suggestion on how to approach this?
The text was updated successfully, but these errors were encountered: