samedi 29 juillet 2017

$(selector).each on table rows w/ Laravel

this is my first question here and I've been searching for a long time about this, also I'm more than a newbie on jQuery and JavaScript in general, but I need it for very small tasks right now so I just got into it without a very deep knowledge of it.

I'm using Laravel 5.4, and I have a table which body is made of a loop on rows because I need it to show results from database, not that it matters, but just for the sake of explaining. I gave an id to an icon that if clicked it will perform some actions, first of all rendering a confirm message and then deleting the row if yes is clicked.

The problem is that I can make that rendered if the first row's icon is clicked, but not for the others. I tried the each method but it seems that's not working, and probably I misread the documentation or I'm not understanding its usage

My code for that is really simple (not performing the delete task):

$('document').ready(function(){
    $('#delete').each(function(){
        $(this).click(function(){
            return!! confirm("Are you sure you want to delete this?");
        });
    });
});

I just want to make the confirm box appear for every icon I click on!

Thanks in advance! If you need me to update the question with some more information please tell me!



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire