0

I have created a collapsible section in fiddler using jquery mobile, which work perfectly fine and all the section does collapse https://jsfiddle.net/ashishrawat/cduhkLm0/

However when i take the same page and display it in webview, it doesn't work. I have inspected it in chrome and I get the same element(html) as jsfiddle, excluding the header, also there is no error in console. 
My page rendering code in android is pretty standard
    webView.addJavascriptInterface(
                        inspectView.new SurveyJSInterface(), "HTMLOUT");
                //webView.loadUrl(mSurveyUrl);
                //webView.loadDataWithBaseURL("file:///android_asset/", fileContent, "text/html", "UTF-8", null);
                webView.loadDataWithBaseURL("file:///android_asset/index.html", fileContent, "text/html", "UTF-8", null);
                webView.setInitialScale(1);
                webView.getSettings().setSaveFormData(true);
                webView.getSettings().setLoadWithOverviewMode(true);
                webView.getSettings().setUseWideViewPort(true);

HEader section $(document).bind('mobileinit',function(){ $.mobile.pushStateEnabled = false; });

Only difference which i could see is fiddler is using jquery 1.4.4 while i am locally using 1.4.5 However i don't think that matters. Please suggest !

Ashish Rawat
  • 5,541
  • 1
  • 20
  • 17
  • How does your index.html look like? Are you using? – mika Oct 21 '15 at 15:46
  • Index.html only show javascripts ...element file contain the meta tags in header.. which i have pasted in main question as this comment has character limit. Please suggest – Ashish Rawat Oct 22 '15 at 08:08
  • Make sure you libraries (JQuery) are loading properly, maybe using file:// protocol is throwing security errors. Try adding an image next to your index.html and try loading it on the page to see if it shows. – mika Oct 22 '15 at 15:28
  • yes it does, i tried surrounding a div with h1 tag to see if jquery working and it worked ! – Ashish Rawat Oct 22 '15 at 17:10
  • what if you host the form on a server? just for testing of course. – mika Oct 22 '15 at 17:22
  • yes it works !! thats really strange !when i put the resultant code in html file and refer in my webview using same method, it works !!! – Ashish Rawat Oct 25 '15 at 15:23

1 Answers1

0

The reason was simple. The page is modified after dom is loaded hence need to refesh the form using.

$("#formid").trigger("create");

Ashish Rawat
  • 5,541
  • 1
  • 20
  • 17