Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

Jquery function call in jquery loaded data

  • 21-10-2012 05: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,477 ✭✭✭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
Advertisement