Side navigation
#11428 closed bug (duplicate)
Opened March 02, 2012 03:04PM UTC
Closed March 02, 2012 03:23PM UTC
Last modified March 02, 2012 06:51PM UTC
$(document).one('focus', selector, function) does fires more that once.
Reported by: | bart@bartmax.com | 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:
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.