Bug Tracker

Opened 6 years ago

Closed 6 years ago

#13737 closed bug (notabug)

.on triggered only once.

Reported by: lolka_bolka Owned by:
Priority: undecided Milestone: None
Component: unfiled Version: 1.9.1
Keywords: Cc:
Blocked by: Blocking:

Description

Documentation says:

A selector string to filter the descendants of the selected elements that trigger the event. If the selector is null or omitted, the event is always triggered when it reaches the selected element.

I am having a link, and when i click on that, the content of the parent div is changed by ajax.

If i am using this:

$('.calendar_next_month, .calendar_prev_month').on('click', function(e) {

then it loads the content. the content came from a function, so the loaded content include the links with the specified selector.

after that, when i clicked on the link, the .on not triggered.

if i am using on this way:

$(document).on('click', '.calendar_next_month, .calendar_prev_month', function(e) {

it works.

I think, this is bug, because the documentation says, "the selected elements that triggered". In the first case, the triggered element has no descendant, so it shouldn't trigger the .on, bacause it will never reach the selected element, because selected element is the element that triggered.

Summarize: in the first case, it shouldn't work, but works.

Change History (1)

comment:1 Changed 6 years ago by m_gol

Resolution: notabug
Status: newclosed

You most likely change contents of the parent div so those children no longer exist. Please ask for support on forums, this is not a bug.

Note: See TracTickets for help on using tickets.