Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Jquery function call in jquery loaded data

Options
  • 21-10-2012 6:56pm
    #1
    Registered Users Posts: 1,987 ✭✭✭


    I have data being loaded on a page using the jquery .load() function which calls a php script and is working grand. I have pagination added to the data loaded onto the page but no jquery functions work when I click on the pagination in the data that has been loaded.

    Does this mean that jquery .click() function wont work on data if that data has been loaded by another jquery function and if so is there a way around this?


Comments

  • Registered Users Posts: 6,464 ✭✭✭MOH


    .click won't work for dynamically added elements.

    You'll need to use .delegate or .live

    Have a look at this

    [edit] Actually just re-read that properly myself, .live is deprecated, probably best using .on:
    $(document).on("click", "element", function() {whatever you want to do});


  • Registered Users Posts: 1,987 ✭✭✭Ziycon


    Nice one MOH, works perfectly.


Advertisement