Beta release - cannot run javascript using onclick?? #1887

stopsusa opened this Issue Jun 22, 2011 · 14 comments


None yet

7 participants

  • My Profile
  • Worked without a problem in last alpha release

    <script type="application/x-javascript"> function my_profilel(ck_username, ck_member, get_profile ){ alert('testing my_profile onclick); } </script>

    Please advise

    Thanks - Any and all help appreciated

    forrest commented Jun 22, 2011

    This has broken a significant amount of my code. I'm replacing them all with a binding to the "vclick" event, but I'm not happy about this change.


    @forrest Agreed, I just changed all bindings to vclick and now my test Android (2.3) ajax navigation is broken. The vclick event is not being caught and the page is being requested as normal. Changing back to using click for everything. Let you know how it all goes.


    I am finding a few problems in Android ajax navigation in 2.3 as of the Beta release. In order for ajax navigation to work consistently and to be able to use 'click' events you have to set $.mobile.useFastClick = false. Also look out for this guy, #1904.

    samspot commented Jun 29, 2011

    Please see this thread for more info:

    I'm personally finding that for links it only fails on iphones, and only when href='#'. However I did notice that onclick wasn't working for divs.

    @jblas jblas was assigned Jun 29, 2011

    You can turn off $.mobile.useFastClick and your click events will work again, but there will be a delay on iOS and other touchscreen devices. Ideally, you'd switch to using vclick in your code to speed up the responsiveness.


    BTW - you need to use latest instead of beta 1 if you want to disable this feature.

    samspot commented Jun 29, 2011

    I can confirm that turning off $.mobile.useFastClick does not affect this issue in beta1.


    Did you try latest? There was an issue in beta 1 that made turning this off not work.

    jblas commented Jun 29, 2011


    How and when are you turning off $.mobile.useFastClick? There was a bug where toggling that option didn't do what it advertised. This is why Todd said you need to try the latest.

    samspot commented Jun 29, 2011

    No, I haven't tried it yet, and we're overbudget on our jquery mobile upgrade task, so we cannot afford to upgrade again at this time :(

    The workaround we found is working well enough for now:
    a href="javascript:void(0);" onclick="alert('goodbye');">Goodbye</a

    This works on all the devices we tested and doesn't require us to refactor existing javascript.

    Edit: Had to deform the a tag to keep markdown from making it an actual link


    This is now fixed in master.

    @toddparker toddparker closed this Jun 30, 2011

    Just replace href="#" with href="javascript:" , this will trigger the OnClick code.

    • Praveen

    using href="javascript:" isn't a recommended approach for a number of reasons, but it is especially bad because it breaks the PE approach.


    Jqm beta2 is stable ... switch to beta2

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