Rails的3 AJAX远程形式回调 [英] Rails 3 AJAX remote form call backs

查看:136
本文介绍了Rails的3 AJAX远程形式回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从栏杆2.3.8至3.0.0升级,所以我需要替换 remote_form_for 帮助调用的form_for(@object ,:远程=>真)

I'm upgrading from rails 2.3.8 to 3.0.0, so I need to replace the remote_form_for helper calls with form_for(@object, :remote=>true).

我一直在跟随着西蒙娜Carletti酒店但我似乎无法获得 rails.js 的AJAX回调火灾。

I've been following along with Simone Carletti but I cant seem to get the ajax callbacks from rails.js to fire.

我生成的HTML是:

<form accept-charset="UTF-8" action="/vendor_shipments" class="new_vendor_shipment" data-remote="true" id="formname" method="post">

我测试JavaScript的使用:

The javascript I'm testing with:

jQuery(function($){ 
   alert('document ready');
   $("#formname")
      .bind('ajax:loading', function() {alert("loading!");})
      .bind('ajax:success', function(data, status, xhr) {alert("success!");})
      .bind('ajax:failure', function(xhr, status, error) {alert("failure!");})
      .bind('ajax:complete', function() {alert("complete!");});
});

文档准备好的警报火灾,以及Ajax请求成功执行(数据被发送到服务器),但没有任何的 AJAX:____ '回调火灾。

我是什么做错了吗?

(对于它的价值,形式本身通过AJAX加载)

(for what it's worth, the form itself is loaded via ajax)

推荐答案

哇,那是一个晚上的巨大浪费。

Wow, that was a colossal waste of an evening.

做它,我做的方式,默认的原型 rails.js 将不衔接的回调。

Doing it the way I did, the default prototype rails.js won't linkup the callbacks.

变换为基于jQuery的后 rails.js (http://github.com/rails/jquery-ujs)回调工作正常。

After converting to the jQuery based rails.js (http://github.com/rails/jquery-ujs) callbacks are working fine.

这篇关于Rails的3 AJAX远程形式回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆