Created
March 2, 2013 10:23
-
-
Save thinkphp/5070418 to your computer and use it in GitHub Desktop.
Event Delegation on CUI2 AMD Style
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
| require(["ready","dom","delegate"], function(r, dom, d){ | |
| var ready = r.ready, | |
| delegate = d.delegate; | |
| ready(function(){ | |
| delegate(dom.select("#menu"), 'li a', 'click', function( e ){ | |
| var ul = e.target.parentNode.querySelector("ul") | |
| if(ul.style.display == "none") { | |
| ul.css("display: block") | |
| } else { | |
| ul.css("display: none") | |
| } | |
| if(window.console) console.log(e.target) | |
| }, false); | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment