LoginSignup
3
3

More than 5 years have passed since last update.

form_for remote:true の時にajax:failure、ajax:loadingがコールされない

Posted at

ハマりまくって時間を食ってしまったが、ようするにイベントの名前が違うらしい。この名前変更っていつ起きたものなのだろうか。読んだ資料が古かったんだろう。

http://stackoverflow.com/questions/6004189/rails-remote-form-callback-ajaxloading-does-not-fire-others-do
によるとajax:[jqueryでのイベント名]っぽい。実際のソースをたぐってみると下記のように書いてあった。

       options = {
          type: method || 'GET', data: data, dataType: dataType,
          // stopping the "ajax:beforeSend" event will cancel the ajax request
          beforeSend: function(xhr, settings) {
            if (settings.dataType === undefined) {
              xhr.setRequestHeader('accept', '*/*;q=0.5, ' + settings.accepts.script);
            }
            return rails.fire(element, 'ajax:beforeSend', [xhr, settings]);
          },
          success: function(data, status, xhr) {
            element.trigger('ajax:success', [data, status, xhr]);
          },
          complete: function(xhr, status) {
            element.trigger('ajax:complete', [xhr, status]);
          },
          error: function(xhr, status, error) {
            element.trigger('ajax:error', [xhr, status, error]);
          },
          crossDomain: crossDomain
        };
3
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
3