1

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

Community
  • 1
  • 1
Oscar Gomez
  • 18,436
  • 13
  • 85
  • 118
  • This may sound stupid but did you include jQuery? Also you can also try using jQuery Mobile CDN files directly just to be sure. – Gajotres May 22 '13 at 17:06
  • @Gajotres well probably not, what exactly do I have to do include jQuery? – Oscar Gomez May 22 '13 at 17:13
  • Just before jquery.mobile-1.3.1.min.js, jQM cant work without jQuery. Pick version 1.9+ – Gajotres May 22 '13 at 17:15
  • I will try that, that might be it, thank you! – Oscar Gomez May 22 '13 at 17:33
  • I would recommend reading the "Getting Started" section on the jQuery Mobile website (and in general reading at least some documentation before messing with a new framework): http://learn.jquery.com/jquery-mobile/getting-started/ – Jasper May 22 '13 at 22:21

1 Answers1

1

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.

Gajotres
  • 57,309
  • 16
  • 102
  • 130
  • Thank you, I am sure that is part of the issue, I added version 1.9.1 and added this line: But it is still not working, I also added the file to the copy bundle resources. Is there anything else that I need to do? – Oscar Gomez May 22 '13 at 18:36
  • It seems like it is definitely doing something now, I forgot to load the files using stringByEvaluatingJavaScriptFromString, it seems like it cannot find the images assets now, there is supposed to be a + and - image to expand and collapse, I added the zip folder I got from downloads to the project but it still can't find them – Oscar Gomez May 22 '13 at 19:06
  • I tried pointing to the cdn i do get the graphics and everything that way, but is there any way to reference this locally? – Oscar Gomez May 22 '13 at 19:14