$("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 Feb 29, 2012 · 10 comments

9 participants


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:
Render: http://jsbin.com/ocezih/3
Code: http://jsbin.com/ocezih/3/edit#javascript,html

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.


.live() is deprecated


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

@JFK99 JFK99 closed this Mar 1, 2012
jQuery Foundation member

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 http://api.jquery.com/live/ :

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

@gseguin gseguin reopened this Mar 2, 2012
@gseguin gseguin added a commit that closed this issue Mar 8, 2012
@gseguin gseguin 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
@gseguin gseguin closed this in b52d7ca Mar 8, 2012
@gseguin gseguin reopened this Mar 8, 2012
jQuery Foundation member

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

jQuery Foundation member

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


@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.


@scottjehl @JFK99 There hasn't been any updates or comments on this issue in over 2 years. Can you confirm if it's still an issue with the latest jQM version or if this can be closed? Thanks

jQuery Foundation member

These core versions are no longer supported infact we don't support any core version in which live is not deprecated. ( and only one version where it exists at all ) i'm going to close this.

@arschmitz arschmitz closed this Oct 22, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment