Jquery mobile hashListeningEnabled continues to listen for hash changes, even if set to false

I realized 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> 

Do not call navigation. However, this is so. I really would like to disable hash listening so that I can handle events myself.

Am I missing something? Or is this a mistake?

+4
source share
1 answer

$.mobile.ajaxEnabled= false; should work, I will look at it.

Otherwise, just remove href and do everything manually using $ .mobile.changePage

Edit

I did some testing and it looks like you need to switch to RC3 because of this new option:

New linkBindingEnabled Option

jQuery Mobile will automatically snap clicks to anchor tags in your document, even if the AJAX navigation function is disabled so that we can handle interaction states and other functions. For people who are looking for an easy way to say โ€œhands offโ€ on all links, setting the new global binding parameter linkBindingEnabled to false will prevent all binding manipulations, including adding an active button state and blurring alternative links. This should only be used when trying to delegate click control to another library or special code.

  $(document).bind('mobileinit', function () { $.mobile.hashListeningEnabled = false; $.mobile.linkBindingEnabled = false; }); 

It works for me!

+10
source

Source: https://habr.com/ru/post/1381423/


All Articles