Permalink
Browse files

Fixed multiple-inclusion check for compatibility with jquery 1.8.

  • Loading branch information...
1 parent 8a642e4 commit 3d5c7ce1cb27d1323f7df7d1970352d428b405df @JangoSteve JangoSteve committed Aug 16, 2012
Showing with 16 additions and 2 deletions.
  1. +1 −1 src/rails.js
  2. +15 −1 test/public/test/override.js
View
@@ -48,7 +48,7 @@
// Cut down on the number if issues from people inadvertently including jquery_ujs twice
// by detecting and raising an error when it happens.
var alreadyInitialized = function() {
- var events = $(document).data('events');
+ var events = $._data(document, 'events');
return events && events.click && $.grep(events.click, function(e) { return e.namespace === 'rails'; }).length;
}
@@ -39,7 +39,7 @@ asyncTest("the getter for an element's href works normally if not overridden", 1
});
asyncTest("the event selector strings are overridable", 2, function() {
- var documentClickBindings = $(document).data('events').click,
+ var documentClickBindings = $._data(document, 'events').click,
linkClickBinding = $.grep(documentClickBindings, function(a) {
return a.selector.indexOf('a[data-remote]') != -1;
})[0];
@@ -51,4 +51,18 @@ asyncTest("the event selector strings are overridable", 2, function() {
start();
});
+// Not sure why this test isn't working in jquery 1.7,
+// or why the error message doesn't show in the console in 1.8
+// when the test is run.
+//
+//asyncTest("including jquery-ujs multiple times throws error", 1, function() {
+// var script = document.createElement( 'script' );
+// script.type = 'text/javascript';
+// script.src = '/src/rails.js';
+// raises(function() {
+// $("#qunit-fixture").append( script );
+// }, 'appending rails.js again throws error');
+// setTimeout(function() { start(); }, 50);
+//});
+
})();

0 comments on commit 3d5c7ce

Please sign in to comment.