PHP code example of laravel-creative / jquery-actions

1. Go to this page and download the library: Download laravel-creative/jquery-actions library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

laravel-creative / jquery-actions example snippets

 
JqueryAction::onClick($function, $options = [])

<button {{JqueryAction::onClick(function($request){ echo 'Hello'; })}}>Say Hello</button>

$options = [
             'url'=>null, //Ajax Request Url
             'method'=>'POST', //Ajax Request Method
             'onetime'=>false, //Allow One Time Request to this secured url, only work with built in urls.
             'jquerySuccessCallback'=>null, //The callback when success response, you can write jquery codes here and use the data as response, or use JqueryHelpers
             'jqueryErrorCallback'=>null, //The callback when error response, you can write jquery codes here and use the data as response, or use JqueryHelpers
             'onLoadCallback'=>null, // The javascript call back when function started
             'expires'=>20 //Function Expires after 20 second , only work with built in urls.
];

JqueryAction::on($attribute,$function,$options=[])

JqueryAction::static($selector,$method,$function,$options=[])
html
  {{JqueryAction::jqueryForm(function (\Illuminate\Http\Request $request){
      $post=new \App\Post();
    $post->text=$request->text;
    $post->user_id=$request->user()->id;
    $post->save();
    return $post->text;
},[
    'onetime'=>false,
    'expires'=>1200,
    'jquerySuccessCallback'=>\LaravelCreative\JqueryAction\Helpers\JqueryHelper::append('#posts','<li>','New Post {data}','</li>'),
    'onLoadCallback'=>\LaravelCreative\JqueryAction\Helpers\JqueryHelper::jqueryAlert('Loading','Form Is Sending...'),
])}}