$(".projectlegs").on("beforeDelete", function(e, item) { if (! confirm("Are you sure you want to delete this item?")) { return false; } return true; });
This is all based off of https://github.com/wbraganca/yii2-dynamicform. I'm simply wanting to make it more informative as it can be easy to press the wrong deletion button in a listing and end up accidently deleting the wrong row.
leakim971
how many button do you have on the page? if only one, how do you know what row to delete?
ok so you have this code using the class : projectlegs
but your button don't have this class, how the code is executed?
Daniel Pineault
ASKER
Not 100% sure, as I'm simply using a widget created by someone else, I haven't dissected it (nor do I have the expertise to do so). All I know is that I can use
to provide a custom prompt to the user (this works). The question being how can I extract the value of individual controls from the e or item in the function or some other variable that I'm not aware of. item.innerhtml seems to return the <tr></tr> content for the clicked row (so the html I originally supplied), but from that, how can I extract the value of the LocOring control.
Now with your code I was able to write the following, but is it the best way to do this?
var i = $(":hidden[name^='rowSeqNo']", item).val(); //Get the number of the row selected for deletion to be able to build the other control name fromvar LocOrigin = document.getElementById('projectslegs-'+i+'-locorigin').value;alert(LocOrigin); // returns correctly the value of the LocOrigin input for the row selected for deletion
First, you post a row in your first code snippet but I don't see any delete button in that row