Created
September 27, 2011 22:07
-
-
Save jgable/1246402 to your computer and use it in GitHub Desktop.
document.ready alternatives for jQuery Mobile - core.js
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
// Create our namespace object, use one that already exists if it's available, fall back to new object "{}". | |
var MYAPP = MYAPP || {}; | |
(function($, ns) { | |
// .. This is a closure, so we don't muddy up our global namespace. | |
// .. $ = jQuery, ns = MYAPP (For those playing along at home) | |
// Extend our namespace with some stuff we're going to add later. | |
ns = $.extend(ns, { | |
options: {}, // MYAPP.options | |
pages: {} // MYAPP.pages | |
}); | |
}(jQuery, MYAPP)); |
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
// Set up our "home" page class and let it respond to events. | |
(function($, ns) { | |
// See http://jquerymobile.com/test/docs/api/events.html for more info about events | |
function homePage() { | |
}; | |
homePage.prototype.init = function($page, pageDom) { | |
alert("In the init event boiiii!"); | |
}; | |
homePage.prototype.show = function($page, pageDom) { | |
alert("In the shown event, yeaaahhhh booiiiii!"); | |
}; | |
// "Export" the page to our pages namespace. | |
ns.pages = ns.pages || {}; // Some safety fall backs in case the pages namespace isn't created yet. | |
ns.pages.home = new homePage(); | |
}(jQuery, MYAPP)); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment