Skip to content

Execute handler functions with scope ControllerObject #22

merged 1 commit into from Feb 13, 2012

2 participants


I would like handler functions to be executed in the ControllerObject scope (instead of the current no-scope). This allows you to use this in the ControllerObject/handler functions. Additionally, you could extend handlers with a scope keyword.

var router=new $.mobile.Router([
  { "#page": { handler: "page", events: "s" }},
  { "#test": { handler: "test", events: "s" }}],
    sharedFunction: function(page) {
      // initialize footer on page
    page: function(eventType, matchObj, ui, page, evt) {
      // other logic

I'm trying to learn git/github, so let me know if I did something wrong...


Perfect, thanks for the patch.

I'll fix a small potential issue in a further commit, because the ControllerObject passed to the router is now just copied into an empty object {} [ cfr: $.extend(this.userHandlers,userHandlers||{}) ].
It's better to keep a reference to the original object, if provided by the user.

@azicchetti azicchetti merged commit 3661d34 into azicchetti:master Feb 13, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.