mabs/jquery-ajax-bundle

此包提供了一些Twig函数,用于生成发送Ajax请求的JavaScript函数。

安装: 221

依赖: 0

建议者: 0

安全: 0

星标: 6

关注者: 2

分支: 2

开放问题: 0

类型:symfony-bundle

v1.1 2014-02-19 16:21 UTC

This package is not auto-updated.

Last update: 2024-09-28 13:52:59 UTC


README

Build Status Scrutinizer Code Quality GitHub issues GitHub stars GitHub license

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许可证下获得。