Possible innacuracy in .on() documentation #290

Closed
FrancoB411 opened this Issue Apr 30, 2013 · 0 comments

Comments

Projects
None yet
1 participant

On this page:
http://api.jquery.com/on/

In this section:
Example: Attach and trigger custom (non-browser) events.

Starting on line of code 15:
$("p").on("myCustomEvent", function(e, myName, myValue){
$(this).text(myName + ", hi there!");
$("span").stop().css("opacity", 1)
.text("myName = " + myName)
.fadeIn(30).fadeOut(1000);
});
$("button").click(function () {
$("p").trigger("myCustomEvent", [ "John" ]);
});

myValue does not seem to be used. Maybe remove it?
If the idea is to show that the custom events can pass multiple values into the handler such as $("p").trigger("myCustomEvent", [ "John", "DAN" ]);
Then maybe add a second value like DAN to the array, like in the line above, and use the myValue argument in the handler to display DAN to the screen?

Whatever the intention, Hope this helps.

Best,

F

dmethvin closed this in 8f055c0 May 16, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment