1

Please can somebody explain in more detail what $.mobile.hashListeningEnabled does when enabled/disabled in jQuery Mobile?

I have tried debugging the source, but there are some bits of code I do not fully understand. And the documentation is a bit abstract (https://api.jquerymobile.com/global-config/):

jQuery Mobile will automatically listen and handle changes to the location.hash. Disabling this will prevent jQuery Mobile from handling hash changes, which allows you to handle them yourself or use simple deep-links within a document that scroll to a particular id.

The reason I ask, is because I am having problems on iOS 9 with <select data-native-menu="false"> elements. If this list too long, jQuery Mobile creates a full-screen dialog.

But it closes straight after displaying. I have been looking around and noticed somebody else has the same problem: JQuery .popup("open") not working properly on iOS 9 device.

One answer suggested seems to work OK for me - which is to set hashListeningEnabled to false:

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

But I am not comfortable rolling this out to production until I understand what exactly it does.

$.mobile.changePage seems to still function.

Community
  • 1
  • 1
keldar
  • 6,152
  • 10
  • 52
  • 82

1 Answers1

2

You can have multiple pages in one html file. And you can go to "another page" even if that page is actually another div with data-role="page" in it. http://demos.jquerymobile.com/1.4.5/pages-multi-page/

So, if you are using this type of navigation, you are screwed. Apple guess that somebody could make an XSS attack using hash. /pages-multi-page/#two

popups are using hash also: /pages-multi-page/#&ui-state=dialog

  • This is awesome - thanks! Didn't know you can do XSS with hashes? – keldar Sep 22 '15 at 10:00
  • 2
    I'm not sure that Apple intentionally changed the hashing behaviour to prevent XSS. The problem is that window.location.hash value is set asynchronously in iOS 9.0 UIWebView, which seems more like a bug (see here: https://openradar.appspot.com/22186109), since this is not the case in WkWebView on iOS 9.0 – DaveAlden Sep 24 '15 at 11:59
  • Fingers crossed for iOS 9.1 – DaveAlden Sep 27 '15 at 19:09