New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Binding to <a> or <form> elements' click events before jQM loads breaks navigation #1384

Closed
JangoSteve opened this Issue Apr 6, 2011 · 7 comments

Comments

Projects
None yet
3 participants
@JangoSteve

JangoSteve commented Apr 6, 2011

jQM AJAX navigation breaks if you bind handlers to the click events of any a or form elements with .live() or .delegate() before jquery.mobile-1.0beta-pre.min.js is included in the page. For example:

<script src="/javascripts/jquery.js" type="text/javascript" />
<script type="text/javascript">
  $('a').live('click', function() { console.log('hi'); });
  // or this to:
  $(document).delegate('a', 'click', function() { console.log('hi'); });
</script>
<script src="/javascripts/jquery.mobile-1.0beta-pre.min.js" type="text/javascript" />

However, this works fine:

<script src="/javascripts/jquery.js" type="text/javascript" />
<script src="/javascripts/jquery.mobile-1.0beta-pre.min.js" type="text/javascript" />
<script type="text/javascript">
  $('a').live('click', function() { console.log('hi'); });
</script>

Obviously, this code is an unrealistic example. However, it's not uncommon for jQuery plugins to use live or delegate, which means if you include such a plugin before jQuery Mobile, it breaks, but include the plugin after jQuery Mobile and it works.

Also, this bug did not exist in Alpha 4-pre, only in Beta-pre.

@jblas

This comment has been minimized.

Show comment
Hide comment
@jblas

jblas Apr 6, 2011

Contributor

Hi @JangoSteve,

I can't tell when you pulled your source based on the names you've given ("Alpha 4-pre, Beta-pre). Have you tried this against our current HEAD? I ask because in Alpha 4 we were experimenting with triggering actions on 'a' tags via the new virtual events. This was landed just prior to us releasing Alpha 4, so I'm wondering if your Alpha 4-pre you refer to was before "fastclick" landed. We've since backed off because it causes some very peculiar problems. (See Issue 1331 for details)

Contributor

jblas commented Apr 6, 2011

Hi @JangoSteve,

I can't tell when you pulled your source based on the names you've given ("Alpha 4-pre, Beta-pre). Have you tried this against our current HEAD? I ask because in Alpha 4 we were experimenting with triggering actions on 'a' tags via the new virtual events. This was landed just prior to us releasing Alpha 4, so I'm wondering if your Alpha 4-pre you refer to was before "fastclick" landed. We've since backed off because it causes some very peculiar problems. (See Issue 1331 for details)

@JangoSteve

This comment has been minimized.

Show comment
Hide comment
@JangoSteve

JangoSteve Apr 7, 2011

Sorry, the latest version that I had experienced this with was as of this commit.

JangoSteve commented Apr 7, 2011

Sorry, the latest version that I had experienced this with was as of this commit.

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Apr 28, 2011

Contributor

What is you use vclick instead of click?

Contributor

toddparker commented Apr 28, 2011

What is you use vclick instead of click?

@JangoSteve

This comment has been minimized.

Show comment
Hide comment
@JangoSteve

JangoSteve May 1, 2011

Are you saying replace click with vclick in the other libraries, or in jQuery Mobile?

JangoSteve commented May 1, 2011

Are you saying replace click with vclick in the other libraries, or in jQuery Mobile?

@ghost ghost assigned jblas May 2, 2011

@jblas

This comment has been minimized.

Show comment
Hide comment
@jblas

jblas May 2, 2011

Contributor

@JangoSteve,

I just tried your test and it works on the HEAD ... it prints out both click 'hi' messages. Have you tried the latest source?

  • Kin
Contributor

jblas commented May 2, 2011

@JangoSteve,

I just tried your test and it works on the HEAD ... it prints out both click 'hi' messages. Have you tried the latest source?

  • Kin
@JangoSteve

This comment has been minimized.

Show comment
Hide comment
@JangoSteve

JangoSteve May 13, 2011

Hey sorry I've been absent. I'll pull down the new code into my project and try this again this weekend.

JangoSteve commented May 13, 2011

Hey sorry I've been absent. I'll pull down the new code into my project and try this again this weekend.

@toddparker

This comment has been minimized.

Show comment
Hide comment
@toddparker

toddparker Jun 30, 2011

Contributor

This should now be fixed in master.

Contributor

toddparker commented Jun 30, 2011

This should now be fixed in master.

@toddparker toddparker closed this Jun 30, 2011

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment