简体   繁体   中英

iPhone - Using jquery-mobile in a UIWebView

I have never used jquery before, and I am trying to use it on a UIWebView, I though it would be easy but clearly I must be missing something obvious, I kinda followed this SO JQuery Mobile not working inside UIWebView

I am loading a dynamic html string into my UIWebView and I append at the beginning some styling loaded from a local html file (this works fine), it is something like this:

<html>
    <head>
        <style>
//Some style...
                </style>
        <link rel="stylesheet" href="jquery.mobile-1.3.1.min.css"/> //Is this what i have to do to load it??
        <script src="jquery.mobile-1.3.1.min.js"></script> //Is this what I have to do load it???

//Closing tags...

I also went to jquerymobile.com downloads and got this 2 files:

jquery.mobile-1.3.1.min.css
jquery.mobile-1.3.1.min.js

Which I removed from compile sources and added to copy bundle resources, as suggested in the post above.

Then In body I simply added this sample code from http://jquerymobile.com/demos/1.3.0-rc.1/docs/content/content-collapsible.html

<div data-role="collapsible">
   <h3>I'm a header</h3>
   <p>I'm the collapsible content. By default I'm closed, but you can click the header to open me.</p>
</div>

It is my understanding that after doing this, I should be able to tap the div and it would expand and collapse. Right know it just shows all the text in there tapping does nothing.

Any help on what I am missing or a step by step guide would be awesome.

Thank you

jQuery Mobile needs jQuery to work properly.

Also take care, jQuery Mobile is locked to certain jQuery versions so if you are using jQuery Mobile 1.3.1. then you would need to use at least jQuery 1.8.3 but I recommend you using version 1.9 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM