PHPackages                             laravel-creative/jquery-actions - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. laravel-creative/jquery-actions

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

laravel-creative/jquery-actions
===============================

Turn jQuery into magic with php

v1.0(6y ago)013MITPHPPHP ^7.1

Since Mar 24Pushed 6y agoCompare

[ Source](https://github.com/mustafakhaleddev/jquery-actions)[ Packagist](https://packagist.org/packages/laravel-creative/jquery-actions)[ Docs](https://github.com/mustafakhaleddev/jquery-actions)[ RSS](/packages/laravel-creative-jquery-actions/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

Turn jQuery into magic with php
===============================

[](#turn-jquery-into-magic-with-php)

[![Latest Version on Packagist](https://camo.githubusercontent.com/0ca3eccb5a2f930cfb2607e3d1d0e83e591c36a8498b7aa399ec9059527b4383/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c61726176656c2d63726561746976652f6a71756572792d616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-creative/jquery-actions)[![Build Status](https://camo.githubusercontent.com/b53675da5ee34784c964bb30b4c1cc5f72f66eba1e631cf6da8e5f871ae5d989/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f6c61726176656c2d63726561746976652f6a71756572792d616374696f6e732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/laravel-creative/jquery-actions)[![Quality Score](https://camo.githubusercontent.com/1017d2e80878d44721fa9ac3ddd1a0f8470021ccc580e3e5e2250d89281650ea/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f6c61726176656c2d63726561746976652f6a71756572792d616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/laravel-creative/jquery-actions)[![Total Downloads](https://camo.githubusercontent.com/9a61feaf4f9e00e44168aa4c9259d11cce5744a66f6d68f41e36cd72488da76b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c61726176656c2d63726561746976652f6a71756572792d616374696f6e732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/laravel-creative/jquery-actions)

Tired of jquery ajax ? and laravel blades , now all of those things has been turned into magic , with this creative package you can do all ajax stuff without writing any javascript code. also if you want to write fast laravel function without routes or controllers you can do it , i told u its magic :)

Installation
------------

[](#installation)

You can install the package via composer:

```
composer require laravel-creative/jquery-actions
```

[jQuery Actions](#usage)

- [onClick()](#usage)
- [on()](#on)
- [static()](#static)
- [jqueryForm()](#form)
- [$options array](#options)

[JqueryHelpers](#jqueryhelpers)

- [append()](#append)
- [remove()](#remove)
- [hide()](#hide)
- [show()](#show)
- [html()](#html)
- [console()](#console)
- [alerts()](#alerts)

requires
--------

[](#requires)

This package requires `jquery and jquery-confirm`you can install by cdn

```

```

Usage
-----

[](#usage)

### jQuery Actions

[](#jquery-actions)

Jquery actions is static class with `facades` you can use it on `laravel blades` to do the magic.
all functions are based on jquery ajax and secured hashed urls , of course you can use your own `routes`

 #### onClick()

[](#onclick)

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

when you use this function in blades like this and don`t forget to add `@jqueryScripts` blade directive in the end of your file after jquery scripts.

```
Say Hello
```

when the user click the `Say Hello` button , an ajax request will go to secured hashed url and the response will be `Hello`

- Ok Great , but i want to run the function from controller ?

Then you have to mention the controller and the actions like this. ``` Say Hello ``` - that`s awesome, but i want to use custom url

then you can use `$options` array to make the magic.

```
$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.
];
```

so for custom urls your code would be like this

```
    route('name'),
    'method'=>'POST'
    ])}}>Say Hello
```

- all methods work the same way as function and options

#### on()

[](#on)

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

in javascript you can use `$('#id').on('onmouseenter',function(e){})` to run a method when mouse enter div with id `#id`you can use the same with this package.

```
    route('name'),
    'method'=>'POST'
    ])}}>Say Hello
```

with all `onClick()` magic too. you can use all html attributes on the first parameter

#### static()

[](#static)

```
JqueryAction::static($selector,$method,$function,$options=[])
```

You can make your own static javascript function without inline tag method,

in javascript you can use `$('#id').on('hover',function(e){})` to run a method when mouse hover a div with id `#id`you can use the same with this method. its ajax too.

```
{{JqueryAction::static('#id','hover',null,[
    'url'=>route('name'),
    'method'=>'POST'
    ])}}
```

#### jqueryForm()

[](#jqueryform)

you can do the magic with forms too.
start your form tag

```
  {{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','','New Post {data}',''),
    'onLoadCallback'=>\LaravelCreative\JqueryAction\Helpers\JqueryHelper::jqueryAlert('Loading','Form Is Sending...'),
])}}
```

then add your fields and close the form

```
  {!! JqueryAction::closeForm() !!}
```

### JqueryHelpers

[](#jqueryhelpers)

You saw those keys in `$options` array above

```
'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,

```

how can you use them.
1- you can use pure javascript or jquery functions as `text` instead of `null` to control the ajax response.

```
'jquerySuccessCallback'=>'alert("success :"+ data)',
'jqueryErrorCallback'=>'console.log(error.status)',
'onLoadCallback'=>'alert("loading..")',

```

2-or you can use our `jqueryHelper` functions.

#### append($selector, $openTag, $msg, $closedTag)

[](#appendselector-opentag-msg-closedtag)

uses jquery `append` function

```
'jquerySuccessCallback'=>jqueryHelper::append("#status",'','Success Status : {data.status}',''),
'jqueryErrorCallback'=>jqueryHelper::append("#status",'','Error Status : {error.status}',''),
'onLoadCallback'=>jqueryHelper::append("#status",'','Loading....',''),

```

you can use `{data}` to access javascript data object `{data.msg}`

#### remove($selector)

[](#removeselector)

uses jquery `remove` method to remove element

```
'jquerySuccessCallback'=>jqueryHelper::remove("#loading"),

```

#### hide($selector)

[](#hideselector)

```
'jquerySuccessCallback'=>jqueryHelper::hide("#loading"),

```

#### show($selector)

[](#showselector)

```
'onLoadCallback'=>jqueryHelper::show("#loading"),

```

#### html($selector,$msg)

[](#htmlselectormsg)

change element html

```
'jquerySuccessCallback'=>jqueryHelper::html("#msg",'Success'),

```

#### console($msg)

[](#consolemsg)

write to the console

```
'jquerySuccessCallback'=>jqueryHelper::console('{data.users}'),

```

#### static function function($selector, $function, $msg)

[](#static-function-functionselector-function-msg)

this would print `$('$selector').$function('$msg');";`for example i want to change html of div when success.

```
'jquerySuccessCallback'=>jqueryHelper::function('#text','html','{data.text}'),

```

so the result would be

```
$('#text').html(data.text);
```

#### jqueryAlert($title, $msg)

[](#jqueryalerttitle-msg)

we uses `jquery confirm` alerts to display alerts messages.

```
'jqueryErrorCallback'=>jqueryHelper::jqueryAlert("Error !","cant reach : {error}"),

```

### Changelog

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

### Security

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Mustafa Khaled](https://github.com/laravel-creative)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

2237d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/25182746?v=4)[Mustafa Khaled](/maintainers/mustafakhaleddev)[@mustafakhaleddev](https://github.com/mustafakhaleddev)

---

Top Contributors

[![mustafakhaleddev](https://avatars.githubusercontent.com/u/25182746?v=4)](https://github.com/mustafakhaleddev "mustafakhaleddev (7 commits)")

---

Tags

laravel-creativejquery-actions

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/laravel-creative-jquery-actions/health.svg)

```
[![Health](https://phpackages.com/badges/laravel-creative-jquery-actions/health.svg)](https://phpackages.com/packages/laravel-creative-jquery-actions)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M683](/packages/barryvdh-laravel-ide-helper)[orchestra/canvas

Code Generators for Laravel Applications and Packages

21017.2M157](/packages/orchestra-canvas)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M210](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M858](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
