开发者

how to set timeout in rails UJS?

开发者 https://www.devze.com 2023-04-11 08:39 出处:网络
The new and cool syntax allows me t开发者_如何学运维o write: link_to some_path, :remote => true

The new and cool syntax allows me t开发者_如何学运维o write:

link_to some_path, :remote => true

to generate an AJAX request. But if I need longer timeout(e.g. 100000ms), where can I set it? I read link_to but found nothing.


You can use $.rails.ajax property from jquery-ujs, to inject the timeout if it has not been passed explicitly:

$(function() {
    // ...

    $.rails.ajax = function(options) {
      if (!options.timeout) {
        options.timeout = 100000;
      }      
      return $.ajax(options);
    };

    // ...
});
0

精彩评论

暂无评论...
验证码 换一张
取 消