Thursday, August 20, 2020

Vue js delete ?

 HTML:

<button type="button" @click="deleteComment(row.id,index)" ><i class="fa fa-trash-o text-danger hand"></i></button>

Web.php:

 Route::delete('/delete-ticket-comment/{id}', 'Admin\TaskController@deleteTicketComment')->name('backoffice.delete-ticket-comment');

Controller:

public function deleteTicketComment($id){ 

        $taskComment =TaskRemark::findOrFail($id)->delete(); 

    }

Vue Js 

deleteComment:function(id,index) {

                  var ref = this;

                     swal({

                        title: "Are you sure?",

                        text: "You will not be able to recover this data!",

                        type: "warning",

                        showCancelButton: true,

                        buttonsStyling: false,

                        confirmButtonClass: 'btn btn-primary',

                        cancelButtonClass: 'btn btn-light',

                        confirmButtonText: "Yes, delete!",

                        cancelButtonText: "No, cancel!"

                         

                    }).then((willDelete) => {

                           if (willDelete) {

                                axios({

                                  method:'delete',

                                  url:"{{ url('backoffice/delete-task-comment') }}/"+id, 

                                  

                                }).then(function (response) {

                                     ref.alert('Delete Successful','success');

                                     ref.task_remarks.splice(index, 1);

                             });

                           } else {

                                 return true;

                        }

                    }); 

                

                }

            },


Others :

<script src="https://unpkg.com/sweetalert/dist/sweetalert.min.js"></script>


deleteComment:function(id,index) {

                  var ref = this;

                     swal({ 

                        title: "Are you sure?",

                        text: "You will not be able to recover this data!",

                        icon: "warning",

                        buttons: true,

                        dangerMode: true,

                         

                    }).then((willDelete) => {

                           if (willDelete) {

                                axios({

                                  method:'delete',

                                  url:"{{ url('backoffice/delete-task-comment') }}/"+id, 

                                  

                                }).then(function (response) {

                                     //ref.alert('Delete Successful','success');

                                     swal("Delete Successful!");

                                     ref.task_remarks.splice(index, 1);

                             });

                           } else {

                                 swal("Your imaginary file is safe!");

                        }

                    });  

                }

No comments:

Post a Comment

Ajax load lage with laravel.

 step-1:  HTML <div class="row">                     <div class="col-lg-12">                           <d...