Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8305477
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T18:07:29+00:00 2026-06-08T18:07:29+00:00

I am using jQuery Mobile in an application that runs inside a UIWebView .

  • 0

I am using jQuery Mobile in an application that runs inside a UIWebView. The applicaiton is written in Monotouch and has multiple tabs and one of the tabs shows html5 content within a webview. jQuery Mobile allows the html5 content to have a consistent look and feel to the native sections of the application. I am trying to build functionality in html5 that makes use of jQuery Mobile custom select menus, in other words, selects which have data-native-menu attribute set to false, and here I have encountered a strange problem. I have distilled the problem down to a simple example; here is the code:

<body>
    <div data-role="page" data-theme="b" id="forms">
        <div data-role="content">
             <select id="test" data-native-menu="false">
                 <option value="abc">ABC</option>
                 <option value="def">DEF</option>
                 <option value="ghi">GHI</option>
                 <option value="jkl">JKL</option>
                 <option value="mno">MNO</option>
                 <option value="pqr">PQR</option>
                 <option value="abc1">ABC</option>
                 <option value="def1">DEF</option>
                 <option value="ghi1">GHI</option>
                 <option value="jkl1">JKL</option>
                 <option value="mno1">MNO</option>
                 <option value="pqr1">PQR</option>
                 <option value="abc2">ABC</option>
                 <option value="def2">DEF</option>
                 <option value="ghi2">GHI</option>
                 <option value="jkl2">JKL</option>
                 <option value="mno2">MNO</option>
                 <option value="pqr2">PQR</option>
             </select>
        </div> <!--content-->
    </div> <!-- page-->
</body>

When I run this code in Firefox or Safari it works fine. Also if I run it in Mobile Safari on an iPad it also works fine. But when I run this within the UIWebView in my application the popup only displays and closes correctly when there are a small number of items in the select and the overlay is shown. When, instead, the full screen popup is shown, it goes wrong when the popup is closed. So, for example, with the code that I pasted above, an overlay will be displayed if the select is clicked while the iPad is in portrait mode. But if I turn the iPad so the application is in landscape mode and click on the select, then there will be too many items for an overlay and a full screen popup will display instead. When I then try close this full screen popup, one of two things will happen:

  • 1) The very first time the page is loaded the popup will not close at all. It won’t respond to any touch events at all.

  • 2) If I reload the page content in the webview and try again, now the whole UIWebView will disappear when I try close the popup. This scenario will occur on the second and every subsequent load of the page.

The strange thing is, that when I run the application in debug mode, I do not see any exception being thrown when I try select an item from the popup or if I click on the X to close it. The webview just disappears. I can tell that the webview is gone, because my UITabBarController has a background image that shows on every tab, except on the tab where the UIWebView is, because the webview covers the background image on this tab. When I try close the popup then suddenly the background image is visible on an otherwise empty screen… meaning that the webview is now gone.

I really need to be able to use custom select menus in my html5 content, so am hoping that someone else has encountered this before and knows what is going on here. So, does anyone know what is causing this strange behaviour in UIWebView or know of a workaround for this issue?

My iPad is running iOS version 5.0.1 (9A405) and jQuery Mobile versions that I have tried are alpha 4.1 and 1.1.0. This same issue occurs in both these version of jQuery Mobile. Please let me know if other information regarding my iPad or development setup is needed.

Update:

Please ignore what I say above about the UIWebView disappearing. That is actually not happenning. In fact an exception is occurring in the webview and a redirect is occurring to an error html page embedded in the application package. This error screen has the same background image as on the UITabBarController, hence my jumping to the wrong conclusion. So, I know now that some exception is occurring in the webview, but it is still very much there! 🙂 I will post an update when I know more.

Update 2:

I now know what is going wrong, although I do not quite know yet how to solve it. This is what is happening: when the popup is clicked, jQuery Mobile is adding #&ui-state=dialog to the url. In other browsers this change is being reflected in the browsing history, so the popup is closed by means of a back being done on the browsing history. In the case of my UIWebView the change to the url is not being reflected in the history, so clicking close either does nothing (history is empty) or goes too far back (to a preload screen with just the background image that gets loaded before the actual content is loaded).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T18:07:30+00:00Added an answer on June 8, 2026 at 6:07 pm

    I actually found that this issue was not caused by the UIWebview after all. When I reduced my code to just the webview I found that it worked correctly. This issue occurred because in my webview I was making use of ASIHTTPRequest and this is what was causing the change in the url not to be reflected in the browser history.

    I have not looked at where ASIHTTPRequest is going wrong at this stage, but I think that this is beyond the scope of this question anyway. When I do deal with this issue in ASIHTTPRequest I will post separate question about it.

    I did manage to workaround to this issue, though, and the workaround involves changing the jQuery Mobile source to compensate for the fact that the previous page is not stored in the history. In version 1.1.1 of ‘jQuery Mobile` find the follow code on lines 4177 and 6933:

    window.history.back();
    

    comment these lines out and replace them with the following:

    $.mobile.changePage( $.mobile.urlHistory.getPrev().url );
    

    Now ‘jQuery Mobile` will actually navigate to the previous url rather than replying on the browser history. This is slightly slower than making use of the browser history but is more reliable in situations such as mine when the needed pages are not correctly saved to the history.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using jQuery Mobile for my application that runs mainly on desktop browsers. The
I am developing an application using jquery mobile and flot charts. In That i
I am developing an application using jQuery mobile 1.1.0 RC1 and phonegap 1.5.0 I
We are constructing a mobile web application using PhoneGap and JQuery mobile. Here is
I am using Handlebar in my Rails 3.2 jquery mobile application. I am trying
I'm trying to clean up the architecture of my jQuery Mobile application by using
So here's my problem. I'm currently working on a PhoneGap application using jQuery Mobile
I have an application made by using phonegap 1.5.0 and jquery mobile 1.1.0.... I
I've developed a web-based mobile application using Jquery Mobile and HTML5. Now, can I
I have a Sharepoint application that we're using with mobile browsers. All I'm using

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.