你想实现ajax loading效果,却发现rails的tag里只使用:remote => true
并没有rails2里使用的loading函数。
我看了rails.js,看到
The UJS drivers trigger six events on every AJAX call:
ajax:before
ajax:loading
ajax:success
ajax:failure
ajax:complete
ajax:after
看了这个ticket,就知道并不是所有人了解:
https://rails.lighthouseapp.com/projects/8994/tickets/4486-new-ujs-helpers-do-not-have-a-way-to-render-a-loading-text-icon
his can easily be accomplished each driver has a custom callback that fires before the request is sent, here is an example using the jQuery driver.
$('#new_resource').live('ajax:loading', function() {
// code to display loading div
});
refs:
https://rails.lighthouseapp.com/projects/8994/tickets/4486-new-ujs-helpers-do-not-have-a-way-to-render-a-loading-text-icon
http://www.slideshare.net/adamlogic/jquery-and-rails-sitting-in-a-tree
http://code.alexreisner.com/articles/link-to-remote-with-ujs.html
没有评论:
发表评论