SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Hybrid View

  1. #1
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question jQuery append() issue

    Hi everyone,

    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?

    Many thanks!

  2. #2
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Could you please post some sample code or link us to a demo.
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  3. #3
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Instead of using .click() I think you want to use .on()

  4. #4
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Quote Originally Posted by cpradio View Post
    Instead of using .click() I think you want to use .on()
    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.
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  5. #5
    Hosting Team Leader silver trophybronze trophy
    cpradio's Avatar
    Join Date
    Jun 2002
    Location
    Ohio
    Posts
    4,807
    Mentioned
    141 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by chris.upjohn View Post
    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.
    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

  6. #6
    SitePoint Wizard bronze trophy chris.upjohn's Avatar
    Join Date
    Apr 2010
    Location
    Melbourne, AU
    Posts
    2,183
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Ahh my bad, I actually misread a small word in the first post . You are indeed right on the money cpradio
    Blog/Portfolio | Evolution Xtreme | DFG Design | DFG Hosting | CSS-Tricks | Stack Overflow | Paul Irish
    Having lame problems with your code? Let us help by using a jsFiddle

  7. #7
    SitePoint Zealot
    Join Date
    Apr 2005
    Posts
    149
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Wow, thanks a lot for your great input, guys!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •