#11428 closed bug (duplicate)
$(document).one('focus', selector, function) does fires more that once.
Reported by: | Owned by: | ||
---|---|---|---|
Priority: | undecided | Milestone: | None |
Component: | unfiled | Version: | 1.7.1 |
Keywords: | Cc: | ||
Blocked by: | Blocking: |
Description
one is triggered more than once when the selector is used on one function
HTML:
<input data-autocomplete-source="/QuickSearchCity" name="CityName" type="text"> <input data-autocomplete-source="/QuickSearchCountry" name="CountryName" type="text"> <input type="text" id="result" />
SCRIPT:
(function ($) { var i=0; $(document).one('focus', 'input[type="text"][data-autocomplete-source]', function () { $('#result').val(i++) }); })(jQuery);
FIDDLE: http://jsfiddle.net/wybre/3/
Change History (3)
comment:1 Changed 12 years ago by
Keywords: | needsdocs added |
---|---|
Resolution: | → duplicate |
Status: | new → closed |
comment:3 Changed 12 years ago by
Keywords: | needsdocs removed |
---|
Note: See
TracTickets for help on using
tickets.
We discussed this in #jquery-dev today, the actual bug is fixed in (edge) but we could use a clarification in the
.one()
api docs that for the delegated events case the one-ness *still* applies only to the element(s) where you are attaching the event. You do not get one handler run per matching selector, that would require keeping the event permanently attached so that some future element that appears would get its one shot at fame as well.