Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery mobile hashListeningEnabled keeps listening to hash changes even when set to false

It was my understanding that

<script type="text/javascript" src="//ajax.googleapis.com/ajax/libs/jquery/1.7.0/jquery.min.js"></script>
<script type="text/javascript">
$(document).bind('mobileinit', function () {
    $.mobile.ajaxEnabled = false;
    $.mobile.hashListeningEnabled = false;
});
</script>
<script type="text/javascript" src="//code.jquery.com/mobile/1.0rc2/jquery.mobile-1.0rc2.min.js"></script>

and then some html like

<div data-role="content">
    <span id="lat"></span>
    <span id="long"></span>
    <ul data-role="listview" data-inset="true">
        <li>
            <a href="/#nowhere">Check out item one</a>
        </li>
    </ul>
</div>

<div data-role="page" id="nowhere"></div>

Should not cause any navigation to occur. However it is. I really would like to disable hash listening so that I can handle the events myself.

Am I missing something? Or is this a bug?

like image 590
alex.pilon Avatar asked Dec 27 '22 11:12

alex.pilon


1 Answers

$.mobile.ajaxEnabled= false; should work, I will look into that..

Otherwise just remove the href and do everything manually with $.mobile.changePage

Edit

I've done some testing and it seems you have to switch to RC3 because of this new option:

New linkBindingEnabled option

jQuery Mobile will automatically bind the clicks on anchor tags in your document, even if the AJAX navigation feature is disabled in order for us to handle interaction states and other features. For people looking for a simple way to say “hands off” on all links, setting the new linkBindingEnabled global configuration option to false will prevent all anchor click handling including the addition of active button state and alternate link bluring. This should only be used when attempting to delegate the click management to another library or custom code.

  $(document).bind('mobileinit', function () {

      $.mobile.hashListeningEnabled = false;
      $.mobile.linkBindingEnabled = false;

  });

This works for me!

like image 150
GerjanOnline Avatar answered Jan 31 '23 06:01

GerjanOnline