Skip to content

whipsterCZ/laravel-ajax-destroy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 

Repository files navigation

laravel-ajax-destroy

Allows requesting REST destroy() action without sending FORM (by clicking on link)

Installation

  1. Install https://github.com/whipsterCZ/laravel-ajax

  2. Copy source code to your public directory

  3. Add script to your template

<script src="/js/laravel.ajax.js"></script>
<script src="/js/laravel.ajax.destroy.js"></script>

or use browserify

require('laravel-ajax');
require('laravel-ajax.destroy');

Usage

HTML

<a  href="{{ route('model.destroy', $model) }}"
    class="destroy"
    data-confirm="Are you sure?"
>Delete</a>

Laravel action

public function destroy($id)    {
    Model::find($id)->delete();
    return \Ajax::redirectBack();
}

About

Enable calling REST destroy action without creating FORM

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published