app/assets/javascripts/bhf/mootools_ujs.js in bhf-0.8.0 vs app/assets/javascripts/bhf/mootools_ujs.js in bhf-0.8.2
- old
+ new
@@ -15,31 +15,31 @@
- Rails 3 MooTools driver
...
*/
-window.addEvent('domready', function(){
+(function($){
+ var domReadyCallback = function(){
+ rails.csrf = {
+ token: rails.getCsrf('token'),
+ param: rails.getCsrf('param')
+ };
- rails.csrf = {
- token: rails.getCsrf('token'),
- param: rails.getCsrf('param')
+ rails.applyEvents();
};
-
- // rails.applyEvents();
-});
+ window.addEvent('domready', domReadyCallback);
+ document.addEventListener('page:load', domReadyCallback);
-(function($){
-
window.rails = {
/**
* If el is passed as argument, events will only be applied to
* elements within el. Otherwise applied to document body.
*/
applyEvents: function(el){
el = $(el || document.body);
var apply = function(selector, action, callback){
- el.getElements(selector).addEvent(action, callback);
+ el.addEvent(action + ':relay(' + selector + ')', callback);
};
apply('form[data-remote="true"]', 'submit', rails.handleRemote);
apply('a[data-remote="true"], input[data-remote="true"]', 'click', rails.handleRemote);
apply('a[data-method][data-remote!=true]', 'click', function(event){
@@ -155,6 +155,6 @@
});
}
});
-})(document.id);
+})(document.id);
\ No newline at end of file