Created
September 29, 2011 00:22
-
-
Save basketofsoftkittens/1249673 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
masterObj = {} | |
_.extend( masterObj, Backbone.events); | |
masterObj.registry = { | |
models:[] | |
register:function(name,model){ | |
this.models[name] = model; | |
}, | |
get:function(name){ | |
if(this.models[name]) return this.models[name]; | |
return false; | |
} | |
} | |
var model1=Backbone.Model.extend({ | |
initialize:function(){ | |
var model2 = masterObj.registry.get("model2"); // this could also be a promise if the model isnt ready at this time | |
if (model2){ | |
model2.bind("change:property",function(){ | |
// change model1 properties | |
}); | |
} | |
}); | |
var model2 = Backbone.Model.extend({ | |
intitalize:function(){ | |
} | |
}); | |
var view = Backbone.View.extend({ | |
model:model2, | |
events:{ | |
"click elm" : "changeThis" | |
}, | |
initialize:function(){ | |
masterObj.registery.register( "model2", this.model); | |
}, | |
changeThis:function(){ | |
this.model.set({"property":1}); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment