-
-
Save andrewnicols/5354539 to your computer and use it in GitHub Desktop.
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
YUI.add('moodle-block_codex_about-toggler', function(Y) { | |
// Define a name space to call | |
M.block_codex_about = M.block_codex_about || {}; | |
M.block_codex_about.toggler = { | |
init: function() { | |
// Delegate adds a single event listener rather than one per .codex_about_link | |
// There's no need to loop through and get the IDs and then pass them to the eventHandler as the targetted | |
// Node is available to the eventHandler in any case. | |
Y.delegate('click', this.toggleShow, Y.config.doc, '.codex_about_link', this); | |
}, | |
toggleShow: function (e) { | |
// this = M.block_codex_about.toggler | |
// e = the EventFacade | |
// e.currentTarget is the Node which was targetted in the Y.delegate (the .codex_about_link) | |
// e.currentTarget.get('id') is the id of that node | |
console.log(e.currentTarget.get('id')); | |
// e.currentTarget is *only* available when the context (5th argument to Y.delegate) is supplied. | |
// If no context is supplied, the 'this' variable is the targetted Node. | |
// http://yuilibrary.com/yui/docs/api/classes/YUI.html#method_delegate | |
}; | |
}; | |
}, '@VERSION@', { | |
requires: ['node'] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment