Skip to content
This repository

$("a").live("click") returns different values on desktop browsers and on iOS safari since jQuery Mobile 1.1.0 RC1 #3686

JFK99 opened this Issue February 29, 2012 · 8 comments

6 participants

Nicolas Bartoli Ghislain Seguin Eddie Monge Dave Methvin Kin Blas Scott Jehl
Nicolas Bartoli

I capture an event on a click with $("a").live("click"), from that, I want to get the href property of the this link clicked with this.href.
Here is a quick example:

On iOS simulator safari and iOS device safari it returns me # as a link
On desktop chrome and safari, it returns the actual value of the href property

Problem appears on 1.1.0 RC1 but works on 1.0.

Eddie Monge

.live() is deprecated

Nicolas Bartoli
JFK99 commented March 01, 2012

Thanks Eddie!
Nice catch, I changed the live() to on() and reverse the condition. It works on desktop browsers and ios safari

Nicolas Bartoli JFK99 closed this March 01, 2012
Ghislain Seguin

We traced the problem down to a change in the order the bound and delegated handlers are executed in jQuery 1.7.1 (thanks to @dmethvin and @jblas).

Using jQuery 1.6.4 with jQuery Mobile 1.1-RC1 is the recommended workaround. We'll address the problem before jQuery Mobile 1.1 final.

As a side note, in your example you're using a non supported syntax for live. According to :

Chaining methods is not supported. For example, $("a").find(".offsite, .external").live( ... ); is not valid and does not work as expected.

Ghislain Seguin gseguin reopened this March 02, 2012
Ghislain Seguin gseguin closed this issue from a commit March 07, 2012
Ghislain Seguin Replaced vclick and click .bind by the equivalent document.addEventLi…
…stener. This is to ensure that these handlers will be the first to run on vclick and click.

As of jQuery 1.7 delegated event handlers are run before bound handlers. This change ensure that these handlers are run before the ones handled by jQuery. Fixes #3686
Ghislain Seguin gseguin closed this in b52d7ca March 07, 2012
Ghislain Seguin gseguin reopened this March 07, 2012
Ghislain Seguin

I had to revert the commit as it was causing major breakage of our tests.

Dave Methvin

Probably needs code to normalize event.which, since it's not going through jQuery's event normalization. The reference should be okay, but event.preventDefault() needs to be shimmed in oldIE.

Kin Blas
jblas commented March 09, 2012

@scottjehl @toddparker @gseguin

Hey Scott,

Is there any other way we can try to prevent the location bar from dropping? IMO we shouldn't be outright changing hrefs for links for exactly the reason this bug is about ... we don't know what developers are going to be doing in the events/notifications triggered by the framework processing of the link.

Scott Jehl
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.