Skip to content

Instantly share code, notes, and snippets.

@ignacy
Created December 25, 2010 11:18
Show Gist options
  • Save ignacy/754832 to your computer and use it in GitHub Desktop.
Save ignacy/754832 to your computer and use it in GitHub Desktop.
module pattern
var drawEvents = function() {
var popupExists = function (target) {
return !!jQuery(target).find("#sender").length;
};
var getLocationId = function(slots) {
if (!slots) {
return jQuery("#location_id").text();
} else {
return slots.attr("id").split("_")[1];
}
};
return {
thisContextIsPublic : function () {
// I can use getLocationId() and popupExists() functions here
}
}
}();
// Now I can use this object like this:
drawEvents.thisContextIsPublic();
// but I can't do that:
drawEvents.popupExists(jQuery("Slot"));
// popupExists() is private method of drawEvents!
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment