androo — 2012-07-31T04:37:54-04:00 — #1
I am having an issue with a small jQuery plugin that I've created. In particular, I am using append() to add an extra <LI> to a <UL> list. I am also using the click() event on this list, however the items which are appended via jQuery are being ignored. Is there something that I should be aware of?
chris_upjohn — 2012-07-31T07:09:46-04:00 — #2
Could you please post some sample code or link us to a demo.
cpradio — 2012-07-31T07:49:38-04:00 — #3
Instead of using .click() I think you want to use .on()
chris_upjohn — 2012-07-31T08:28:00-04:00 — #4
Using either is perfectly valid in jQuery but from v1.5 its recommend you always use .on() as it handles event delegation at the same time.
cpradio — 2012-07-31T09:27:45-04:00 — #5
I didn't think .click() could apply the event to newly created objects (such as writing a new li tag), but .on() can... Maybe I misread the documentation, but I thought that was one of the advantages of .on versus .click
chris_upjohn — 2012-07-31T09:53:16-04:00 — #6
Ahh my bad, I actually misread a small word in the first post . You are indeed right on the money cpradio
androo — 2012-07-31T10:17:18-04:00 — #7
Wow, thanks a lot for your great input, guys!
system — 2014-10-07T22:44:12-04:00 — #8
This topic is now closed. New replies are no longer allowed.