-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
3 minor additions #13
Conversation
and prevent destroying existing context on view close event
E.g.: commands: { 'commandName': CommandConstructor }
@@ -35,7 +35,7 @@ | |||
this.vent = {}; | |||
_.extend(this.vent, Backbone.Events); | |||
if (_.isFunction(this.initialize)) { | |||
this.initialize(); | |||
this.initialize.apply(this, arguments); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this idea in principle. Just curious if you have found a use case for it yet? Generally my Context objects have only served to map the commands. What sort of parameters are useful in the initialize()
method?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, since I like the idea of all models living in the context, I pass some models into the constructor.
Just noticed I lost |
Note to self: don't add to pull requests while working on the train ;)
* Make Context pass arguments from constructor to initialize() following backbone conventions * Allow bindContext() to also take an existing context instead of constructor * Automatically map commands in Context.commands property E.g.: commands: { 'commandName': CommandConstructor }
Thanks for the contributions and the great discussion! |
Hey,
I've made three minor additions I find very useful:
E.g.:
commands: {
'commandName': CommandConstructor
}
I hope you find them useful. Best regards,
Jonas