alex.pilon
alex.pilon

Reputation: 522

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?

Upvotes: 4

Views: 6593

Answers (1)

GerjanOnline
GerjanOnline

Reputation: 1881

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

Upvotes: 10

Related Questions