Bug Tracker

Modify

Ticket #11428 (closed bug: duplicate)

Opened 15 months ago

Last modified 15 months ago

$(document).one('focus', selector, function) does fires more that once.

Reported by: bart@… Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.7.1
Keywords: Cc:
Blocking: Blocked by:

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

comment:1 Changed 15 months ago by dmethvin

  • Keywords needsdocs added
  • Status changed from new to closed
  • Resolution set to duplicate

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.

comment:2 Changed 15 months ago by dmethvin

Duplicate of #10984.

comment:3 Changed 15 months ago by dmethvin

  • Keywords needsdocs removed

Please follow the  bug reporting guidlines and use  jsFiddle when providing test cases and demonstrations instead of pasting the code in the ticket.

View

Add a comment

Modify Ticket

Action
as closed
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.