Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

Replacing call to data('events') to allow submit event bubbling to work in IE8 #314

Closed
wants to merge 1 commit into from

2 participants

@jayuen

We have an application that uses jquery-ujs (through jquery-rails). We are upgrading to jQuery 1.9.1 and we ran into some issues with submit event bubbling in IE8. Since we are also using the jQuery Migrate plugin, it gives us a warning whenever .data('event') is invoked. Turns out the culprit is line 256 of rails.js inside callFormSubmitBindings:

var events = form.data('events'), continuePropagation = true;

A bit of searching yielded the following from the jQuery blog (http://blog.jquery.com/2012/08/09/jquery-1-8-released/):

$(element).data(“events”): In version 1.6, jQuery separated its internal data from the user’s data to prevent name collisions. However, some people were using the internal undocumented “events” data structure so we made it possible to still retrieve that via .data(). This is now removed in 1.8, but you can still get to the events data for debugging purposes via $._data(element, "events"). Note that this is not a supported public interface; the actual data structures may change incompatibly from version to version.

Unfortunately, there is no public API alternative if data('events') is still relied upon (as it seems to be in this library). In jQuery 1.9.1, the internal API is still there and using it makes the submit event bubbling work again (necessary for < IE9 only).

I would appreciate your thoughts on this.

Jason

@JangoSteve
Collaborator

With jQuery 1.9, we were actually planning to remove this code entirely. In jQuery 1.7, they fixed the issue that this sovled internally and it's no longer needed.

In fact, this function only gets called if using jQuery < 1.7 (see line 354). So changing the function here would actually break for jQuery < 1.7 and it'd never get called for jQuery > 1.7.

Since we only support the last 2-3 versions of jQuery, we can now safely drop this. Thanks, @jayuen, for looking into this and bringing this to our attention.

@JangoSteve JangoSteve closed this
@JangoSteve
Collaborator

This should be fixed now in 6184e4d.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Mar 14, 2013
  1. @jayuen
This page is out of date. Refresh to see the latest.
Showing with 1 addition and 1 deletion.
  1. +1 −1  src/rails.js
View
2  src/rails.js
@@ -253,7 +253,7 @@
// find all the submit events directly bound to the form and
// manually invoke them. If anyone returns false then stop the loop
callFormSubmitBindings: function(form, event) {
- var events = form.data('events'), continuePropagation = true;
+ var events = jQuery._data(form, 'events'), continuePropagation = true;
if (events !== undefined && events['submit'] !== undefined) {
$.each(events['submit'], function(i, obj){
if (typeof obj.handler === 'function') return continuePropagation = obj.handler(event);
Something went wrong with that request. Please try again.