Do not repeat click action when creating a table from another

Do not repeat click action when creating a table from another

goxalogoxalo Posts: 4Questions: 1Answers: 0

Hola, en este ejemplo, como podría hacer para que NO me repita el elemento de la fila si le doy clic nuevamente. Gracias
Hello, in this example, how could I do so that the row element does NOT repeat itself if I click on it again? Thanks
http://live.datatables.net/pewasecu/1/edit

This question has accepted answers - jump to:

Answers

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    How does it repeat itself? Please post the steps top replicate the issue.

    Kevin

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954

    Maybe post more details about the problem you are trying to solve.

    Kevin

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    Answer ✓

    Is this what you are looking for?
    http://live.datatables.net/pewasecu/9/edit

    It uses a global variable to keep track of the clicked row index. If the new clicked row index is different it is processed. Otherwise nothing happens.

    Kevin

  • goxalogoxalo Posts: 4Questions: 1Answers: 0

    Exactly, this is what I was looking for to happen.
    I didn't know how to ask it in a way that would be understandable by both developers and non-developers.
    It would be interesting and very helpful to publish this example that you post for those looking to create a table from another table by selecting elements from the first one, it would be very helpful for many people.
    Thanks

  • goxalogoxalo Posts: 4Questions: 1Answers: 0

    I just noticed a problem that does not allow it to be the complete solution and that is that clicking on one row and then on another and clicking again on the one you already clicked puts it in the following table and so on

  • kthorngrenkthorngren Posts: 21,342Questions: 26Answers: 4,954
    Answer ✓

    Yes, that is correct. The example is provided to guide you toward a solution that meets your requirements. One option is to keep track of the clicked rows in an array. Another option might be add a class to the clicked row and update the jQuery selector to not include that class, for example:
    http://live.datatables.net/pewasecu/12/edit

    Kevin

  • goxalogoxalo Posts: 4Questions: 1Answers: 0
    edited January 2023

    Perfect, it works, maybe just add a semicolon (;) in line 28 of the example..

    console.log('clicked');
          $(this).addClass('clicked');
          var data = table.row( this ).data();
    

    Thank you for your patience and time.

Sign In or Register to comment.