mabs / jquery-ajax-bundle
This bundle provides a Twig functions that generate js function to send ajax request.
Installs: 223
Dependents: 0
Suggesters: 0
Security: 0
Stars: 6
Watchers: 2
Forks: 2
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- symfony/framework-bundle: ~2.0
This package is not auto-updated.
Last update: 2025-03-01 15:45:42 UTC
README
JQueryAjaxBundle for Symfony2.
Install
To install this bundle on your project, add this line to composer.json file:
"mabs/jquery-ajax-bundle": "~1.0"
This bundle add two Twig functions:
##1 - ja_request:
To generate a js code to send an ajax request:
{{ ja_request({'update': '#reponse', 'url': path('new') }) }}
or
{{ ja_request({'update': '#reponse', 'url': path('new'), 'after': 'alert("after");', 'before': 'alert("before");', 'complete': 'alert("complete");' }) }}
=>
$.ajax({ url: "/app_dev.php/new", type: "POST", dataType: "html",beforeSend: function(){alert("before");},success: function( data ){$( "#reponse" ).html(data);alert("after");}});
##2 - ja_link:
To generate a link:
{{ ja_link({'update': '#reponse', 'url': path('new'), 'text': 'new link' }) }}
To add a confirm action on click, you just have to use 'confirm': true, by default the text is "Are you sure you want to perform this action?" then if you want to replace it, use 'confirm_msg': "***".
You can also use those parameters 'before' and 'after' to execute JS code.
##3 - License
This bundle is available under the MIT license.