-
Notifications
You must be signed in to change notification settings - Fork 263
documenting that on() handler accepts .trigger() args #472 #538
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
@@ -136,6 +137,24 @@ $( "form" ).on( "submit", function( event ) { | |||
]]></code> | |||
</example> | |||
<example> | |||
<desc>Pass data to the event handler using the second argument to <code>.trigger()</code></desc> | |||
<code><![CDATA[ | |||
$( "div" ).on( "click", function( event, extraParameter ) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be better to use a more descriptive variable name here. Perhaps person
instead of extraParameter
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Humm. I consciously used that variable name so that it matched the extraParameter
variable name in the signature definition at the top of the on()
docs; that way it'd be a CTRL + F match for anyone wondering WTF the extraParameter
variable was in the signature (as otherwise it wouldn't be searchable).
I'm not sure whether you'd prefer CTRL + F goodness over good variable names; I'm open to change it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I personally don't like having demos with bad variable names (demos should show how real code should be written). I'm fine with whatever the consensus is.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like person
, fwiw.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Happy to go with the consensus as well; PR updated to use person
instead of extraParameter
.
@dmethvin, can you please review this, per @scottgonzalez's comment above, so we can merge this in? Thanks. |
LGTM! |
Updates of this document we need. DefinitelyTyped does not fix the definition unless update the official api document. DefinitelyTyped prohibits the not one argument event handler reason in the official api document. |
There was a good example to "extend". Better this seems good. http://api.jquery.com/jQuery.extend/ <argument name="eventObject" type="Event" />
<argument name="extraParameter1" type="Anything" optional="true" rest="true" />
<argument name="extraParameterN" type="Anything" optional="true" rest="true" /> |
@falsandtru: Correct me if I'm wrong, but your comments are in reference to your PR DefinitelyTyped/DefinitelyTyped#2843. You've got a point... all jQuery event methods (both the "lower level" Currently, this PR only handles the case for |
I ask you to fix because it seems I do not have permission to edit commit this request. |
See #472 for the complete story. Basically;
extraParameter
to the signature, and added further documentation as to how it works. It uses therest="true"
vararg attribute, which currently doesn't show anything, but support is being added in API Sites: Support for varargs grunt-jquery-content#56on()
andtrigger()
.... all separated into separate commits.