Skip to content

Update one.xml - add example that shows multiple event types #353

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

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion entries/one.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?xml version="1.0"?>
<entry type="method" name="one" return="jQuery">
<title>.one()</title>
<desc>Attach a handler to an event for the elements. The handler is executed at most once per element.</desc>
<desc>Attach a handler to an event for the elements. The handler is executed at most once per element per event type.</desc>
<signature>
<added>1.1</added>
<argument name="events" type="String">
Expand Down Expand Up @@ -95,6 +95,19 @@ p { color:red; margin:0; clear:left; }
<code><![CDATA[$("p").one("click", function(){
alert( $(this).text() );
});]]></code>
</example>
<example>
<desc>Event handlers will trigger once per element per event type</desc>
<code><![CDATA[
var n = 0;
$(".target").one("click mouseenter", function() {
$(".count").html(++n);
});
]]></code>
<html><![CDATA[
<div class="count">0</div>
<div class="target">Hover/click me</div>
]]></html>
</example>
<category slug="events/event-handler-attachment"/>
<category slug="version/1.1"/>
Expand Down