Created
January 24, 2012 21:06
-
-
Save tvpmb/1672702 to your computer and use it in GitHub Desktop.
Separating Events/Event-Methods from the View (partial code, 2 examples, one is commented out)
This file contains hidden or 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
//events | |
define([ | |
"namespace", | |
// Libs | |
"use!backbone", | |
// Plugins | |
"use!plugins/backbone.layoutmanager", | |
], | |
function(custom, Backbone) { | |
var Events = function(obj){ | |
obj.events = { | |
"click .drop-menu": "dropMenu", | |
}; | |
obj.dropMenu = function(evt) { | |
alert("Handle the click"); | |
}; | |
} | |
return Events; | |
/* | |
return { | |
events: { | |
"click .drop-menu": "dropMenu", | |
}, | |
dropMenu: function(evt) { | |
alert("Handle the click"); | |
}, | |
} | |
*/ | |
}); |
This file contains hidden or 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
define([ | |
"namespace", | |
// Libs | |
"use!backbone", | |
// Events | |
"events/header", | |
// Plugins | |
"use!plugins/backbone.layoutmanager", | |
], | |
function(namespace, Backbone, Events) { | |
var app = namespace.app; | |
// Create a new module | |
var Main = namespace.module(); | |
// Main header view | |
/* | |
Main.Views.Header = Backbone.LayoutManager.View.extend({ | |
template: "main/header", | |
initialize: function() { | |
//console.log(Events); | |
this.dropMenu = Events.dropMenu; | |
this.events = Events.events; | |
} | |
}); | |
*/ | |
Main.Views.Header = Backbone.LayoutManager.View.extend({ | |
template: "main/header", | |
initialize: function() { | |
new Events(this); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment