Friday, 15 August 2014

php - Mass deleting and single deleting in one page with laravel -



php - Mass deleting and single deleting in one page with laravel -

i got form able destroy multiple items checking checkbox , able delete single item clicking delete button in table row.

because single deletion surrounded form, containing delete method. i'm not sure how handle mass deletion. cause guess i'll need form well.

but because single deletion has form, can't surround form.

also must have space utilize form filters, send post method.

what best solution in laravel? can't utilize action, because need delete method..

html forms work simple interactions editing or creating new resource. when interaction list of items , having multiple possible actions gets complicated (as noticed). that's our new best friend ajax comes in. i'll utilize jquery, although utilize plain javascript (it's lot more work) we'll utilize $.ajax method create our calls server

$.ajax({ url: 'your/target/url', type: 'delete', data: {ids: [1,2,3]}, // example. here insert ids of selected items }).done(function(data){ // gets called if goes }).fail(function(jqxhr, textstatus){ // ooops request returned http error code, bad must have happened });

in controller should able access variable input::get('ids')

php html forms laravel methods

No comments:

Post a Comment