JQuery on Click function does not work when table is expanded from responsive

JQuery on Click function does not work when table is expanded from responsive

ads32wads32w Posts: 5Questions: 2Answers: 0
edited March 2022 in Responsive

When the table is on full screen function below works fine, but if I expand column with grupa_usera_button on small size and click on button alert does not appear.
$('.grupa_usera_button').on('click', function() { alert('Test test'); });
Any ideas?

This question has an accepted answers - jump to answer

Answers

  • colincolin Posts: 15,177Questions: 1Answers: 2,590

    This example from this thread should help, it's demonstrating just that,

    Colin

  • ads32wads32w Posts: 5Questions: 2Answers: 0
    edited March 2022

    I am confused which option to use. I tried both but I have no effect.

  • ads32wads32w Posts: 5Questions: 2Answers: 0

    I read everything twice and I thing these are not solutions for my problem. In my situation JQuery event does not work. Notice that reendered button after expanding row has class '.grupa_usera_button' but after click alert doesn't appear.

  • kthorngrenkthorngren Posts: 20,425Questions: 26Answers: 4,794
    Answer ✓

    I think what you need os to create delegated events, like this example. Take a closer look at the selectors used for the click events in the example Colin linked to. If you still have issues please provide a test case showing what you are doing so we can help debug.
    https://datatables.net/manual/tech-notes/10#How-to-provide-a-test-case

    Kevin

  • ads32wads32w Posts: 5Questions: 2Answers: 0
    edited March 2022

    Yes. I needed delegated events.
    Code above should be changed to:

     $('#data tbody').on('click', '.grupa_usera_button', function() {
     alert('Test test'); });
    

    Thanks for your time.

Sign In or Register to comment.