Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Loading…

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

Closed
JFK99 opened this Issue · 10 comments

9 participants

@JFK99

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.

@eddiemonge

.live() is deprecated

@JFK99

Thanks Eddie!
Nice catch, I changed the live() to on() and reverse the condition. It works on desktop browsers and ios safari
http://jsbin.com/ocezih/56/edit
http://jsbin.com/ocezih/56
:)

@JFK99 JFK99 closed this
@gseguin
Collaborator

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
@gseguin gseguin closed this issue from a commit
@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
b52d7ca
@gseguin gseguin closed this in b52d7ca
@gseguin gseguin reopened this
@gseguin
Collaborator

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

@dmethvin
Owner

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.

@jblas

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

@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

@arschmitz
Owner

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