Permalink
Browse files

Added jquery event binding namespace 'rails' for easy unbinding of al…

…l rails jquery magic.
  • Loading branch information...
JangoSteve authored and josevalim committed Nov 1, 2010
1 parent c499aae commit a9a7b20c1eec8750a1b1bcdd267b77e055e301b5
Showing with 6 additions and 6 deletions.
  1. +6 −6 src/rails.js
View
@@ -63,7 +63,7 @@ jQuery(function ($) {
var jqueryVersion = $().jquery;
if ( (jqueryVersion === '1.4') || (jqueryVersion === '1.4.1') || (jqueryVersion === '1.4.2')){
- $('a[data-confirm],input[data-confirm]').live('click', function () {
+ $('a[data-confirm],input[data-confirm]').live('click.rails', function () {
var el = $(this);
if (el.triggerAndReturn('confirm')) {
if (!confirm(el.attr('data-confirm'))) {
@@ -72,7 +72,7 @@ jQuery(function ($) {
}
});
} else {
- $('body').delegate('a[data-confirm],input[data-confirm]', 'click', function () {
+ $('body').delegate('a[data-confirm],input[data-confirm]', 'click.rails', function () {
var el = $(this);
if (el.triggerAndReturn('confirm')) {
if (!confirm(el.attr('data-confirm'))) {
@@ -87,17 +87,17 @@ jQuery(function ($) {
/**
* remote handlers
*/
- $('form[data-remote]').live('submit', function (e) {
+ $('form[data-remote]').live('submit.rails', function (e) {
$(this).callRemote();
e.preventDefault();
});
- $('a[data-remote],input[data-remote]').live('click', function (e) {
+ $('a[data-remote],input[data-remote]').live('click.rails', function (e) {
$(this).callRemote();
e.preventDefault();
});
- $('a[data-method]:not([data-remote])').live('click', function (e){
+ $('a[data-method]:not([data-remote])').live('click.rails', function (e){
var link = $(this),
href = link.attr('href'),
method = link.attr('data-method'),
@@ -133,7 +133,7 @@ jQuery(function ($) {
};
$(disable_with_form_remote_selector).live('ajax:before', disable_with_input_function);
- $(disable_with_form_not_remote_selector).live('submit', disable_with_input_function);
+ $(disable_with_form_not_remote_selector).live('submit.rails', disable_with_input_function);
$(disable_with_form_remote_selector).live('ajax:complete', function () {
$(this).find(disable_with_input_selector).each(function () {

11 comments on commit a9a7b20

@alexcrichton

This comment has been minimized.

Show comment Hide comment
@alexcrichton

alexcrichton Nov 1, 2010

Contributor

This seems to be causing problems for jQuery 1.4.1 on the tests (very few of them pass). Is this a bug in jQuery 1.4.1 that was fixed in 1.4.2+?

Contributor

alexcrichton replied Nov 1, 2010

This seems to be causing problems for jQuery 1.4.1 on the tests (very few of them pass). Is this a bug in jQuery 1.4.1 that was fixed in 1.4.2+?

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

Looks like event namespacing was not properly introduced until jQuery 1.4.2. Let me check.

Member

neerajdotname replied Nov 1, 2010

Looks like event namespacing was not properly introduced until jQuery 1.4.2. Let me check.

@alexcrichton

This comment has been minimized.

Show comment Hide comment
@alexcrichton

alexcrichton Nov 1, 2010

Contributor

This says they were introduced in 1.2, but maybe not in live?

Contributor

alexcrichton replied Nov 1, 2010

This says they were introduced in 1.2, but maybe not in live?

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

As per this http://docs.jquery.com/Namespaced_Events event namespacing was introduced in jQuery 1.2 . So it should work with jQuery 1.4.1 :-(

Member

neerajdotname replied Nov 1, 2010

As per this http://docs.jquery.com/Namespaced_Events event namespacing was introduced in jQuery 1.2 . So it should work with jQuery 1.4.1 :-(

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

Yes you are right. Not live. I am going to revert it.

Member

neerajdotname replied Nov 1, 2010

Yes you are right. Not live. I am going to revert it.

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

I guess I should be running the test after each commit.

Member

neerajdotname replied Nov 1, 2010

I guess I should be running the test after each commit.

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

When jQuery 1.4.4 comes out then support for jQuery 1.4, 1.4.1 and 1.4.2 will be dropped. At any time the current version of jQuery and the -1 version will be supported going forward.

Before upgrading the code a tag will be created so that people using 1.4, 1.4.1 and 1.4.2 can use that tagged version.

This commit will be back when jQuery 1.4.4 is released.

Member

neerajdotname replied Nov 1, 2010

When jQuery 1.4.4 comes out then support for jQuery 1.4, 1.4.1 and 1.4.2 will be dropped. At any time the current version of jQuery and the -1 version will be supported going forward.

Before upgrading the code a tag will be created so that people using 1.4, 1.4.1 and 1.4.2 can use that tagged version.

This commit will be back when jQuery 1.4.4 is released.

@JangoSteve

This comment has been minimized.

Show comment Hide comment
@JangoSteve

JangoSteve Nov 1, 2010

Member

Hey guys, sorry, that's my fault. I didn't think to re-run the tests when I rebased. I'm slightly confused though, as I've been using this in a Rails 3 project on jQuery 1.4.2 without any problems.

Member

JangoSteve replied Nov 1, 2010

Hey guys, sorry, that's my fault. I didn't think to re-run the tests when I rebased. I'm slightly confused though, as I've been using this in a Rails 3 project on jQuery 1.4.2 without any problems.

@alexcrichton

This comment has been minimized.

Show comment Hide comment
@alexcrichton

alexcrichton Nov 1, 2010

Contributor

The tests all pass in 1.4.2, but it's jquery 1.4.1 which looks like it's not compatible. The tests all fail against jquery 1.4.1, but they pass against 1.4.2

Contributor

alexcrichton replied Nov 1, 2010

The tests all pass in 1.4.2, but it's jquery 1.4.1 which looks like it's not compatible. The tests all fail against jquery 1.4.1, but they pass against 1.4.2

@neerajdotname

This comment has been minimized.

Show comment Hide comment
@neerajdotname

neerajdotname Nov 1, 2010

Member

It is breaking jQuery 1.4.1 and the current version of rails.js supports all the way from jQuery 1.4 to 1.4.3.

Member

neerajdotname replied Nov 1, 2010

It is breaking jQuery 1.4.1 and the current version of rails.js supports all the way from jQuery 1.4 to 1.4.3.

@JangoSteve

This comment has been minimized.

Show comment Hide comment
@JangoSteve

JangoSteve Nov 1, 2010

Member

Oh ok, thanks for the clarification. Sounds like the best course of action, as you pointed out, is to simply wait until support for 1.4.1 is dropped, since this is non-critical.

Member

JangoSteve replied Nov 1, 2010

Oh ok, thanks for the clarification. Sounds like the best course of action, as you pointed out, is to simply wait until support for 1.4.1 is dropped, since this is non-critical.

Please sign in to comment.