[TIMOB-1458] WebView doesn't keep html
GitHub Issue | n/a |
---|---|
Type | Bug |
Priority | Medium |
Status | Closed |
Resolution | Duplicate |
Resolution Date | 2012-06-22T16:24:23.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | iOS |
Labels | n/a |
Reporter | wolef |
Assignee | Neeraj Gupta |
Created | 2011-04-15T02:53:24.000+0000 |
Updated | 2017-03-09T21:29:42.000+0000 |
Description
If I add a local string to the html-attribute and try to get the string back, I'll only get an empty html tag.
var html = '<html><body>Text</body></html>';
var view = Titanium.UI.createWebView();
view.html = html;
alert(view.html);
That code sample still will not work, but for a good reason. Setting the html is an async process, so it returns quickly. In the background, the web view is loading up your HTML and rendering it. When you inspect the html property right away, it will be whatever the web view had in it before you set the html property. In this case, it will be something like "". If you listen for the "load" event, you'll see your HTML returned. I expanded your example to show how to properly handle this:
Dup of TIMOB-8293
Closing ticket as duplicate.