mabs / jquery-ajax-bundle
此包提供了一些Twig函数,用于生成发送Ajax请求的JavaScript函数。
v1.1
2014-02-19 16:21 UTC
Requires
- php: >=5.3.0
- symfony/framework-bundle: ~2.0
This package is not auto-updated.
Last update: 2024-09-28 13:52:59 UTC
README
JQueryAjaxBundle for Symfony2.
安装
要将此包安装到您的项目中,请在composer.json文件中添加此行
"mabs/jquery-ajax-bundle": "~1.0"
此包添加了两个Twig函数
##1 - ja_request
用于生成发送Ajax请求的JavaScript代码
{{ ja_request({'update': '#reponse', 'url': path('new') }) }}
或
{{ 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
用于生成链接
{{ ja_link({'update': '#reponse', 'url': path('new'), 'text': 'new link' }) }}
要添加点击确认动作,您只需使用'confirm': true,默认文本为"您确定要执行此操作?",如果要替换它,请使用'confirm_msg': "***"。
您还可以使用'before'和'after'参数来执行JavaScript代码。
##3 - 许可证
此包可在MIT许可证下获得。