Having last clicked row values as array
Having last clicked row values as array
Hello everyone,
I have edit button in each row. I'm trying to keep the values in the row of the edit button I clicked last as an array. But it does not work. When I click first edit button in first row, a modal window appears. I close the the modal window and then click second edit button in second row. Below code gets all data of first and second rows but I only want the last row data. How can I make that happen?
In short, when I click on the first edit button, I keep the data of that row on the appeared modal window, but when I close the that window and click on the edit button of the second row, I see the data of both the first row and the second row on the window. What I want is to see only the information of the row I clicked on.(Maybe it is javascript issue?)
var fakeArray = table.rows().data().toArray();
Answers
Are you using the Select extension?
https://editor.datatables.net/manual/getting-started#DataTables-initialisation
If so and you are using single select you could do:
Use a delegated event handler like this example. You my need to make the selector more specific then get the closest
td
ortr
, for example:This will get all the rows in the table.
Kevin
Thank you for the responds. I think it is a bit out of datatables topic but I wanna ask anyway. Let me explain the problem briefly.
I have edit modal and inside this model I have switch button call new modal. And when I switch this button that new modal window appears with data of the rows(problem is here because the whole data of first and second rows appear).
In the code below, when I call the alert function, 1 and then, 2 appear on the screen (first and second rows ids). It should have appeared only 2 because the edit button I clicked last is on the second row.
In short, it enters into the** is_index_sample_edit function** twice even though I click switch button once! I couldn't understand the logic. Sorry it is a bit confusing.