Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

Jquery function call in jquery loaded data

  • 21-10-2012 06:56PM
    #1
    Registered Users, Registered Users 2 Posts: 1,991 ✭✭✭


    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, Registered Users 2 Posts: 6,475 ✭✭✭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, Registered Users 2 Posts: 1,991 ✭✭✭Ziycon


    Nice one MOH, works perfectly.


Advertisement