android - Webview not loading again while clicking on the tab again -


i'm working titanium , developing tabbed application same kitchen sink

my home tab loads html data json file here code,

homecontent.js  function homewindow(title) { var self = ti.ui.createwindow({     title:title,     backgroundcolor:'white' }); var filename = 'includes/homecontent.json'; var file = titanium.filesystem.getfile(titanium.filesystem.resourcesdirectory, filename); var preparsedata = (file.read().text); var response = json.parse(preparsedata); var content = response[0].content; var webview = titanium.ui.createwebview({data:content}); self.add(webview); return self; };  module.exports = homewindow; 

it working first time while click again not call particular html again.

for more reference here tab generating code, don't think creates problem,

var homewindowwin = new homewindow(l('homecontent')); var hometab = ti.ui.createtab({     title: l('home'),     icon: '/images/tabs/ks_nav_ui.png',     window: homewindowwin }); homewindowwin.containingtab = hometab; self.addtab(hometab); 

stuck highly appreciate.

i solved load event of tab assigns again webview see edited code below,

function homewindow(title) { var self = ti.ui.createwindow({     title:title,     backgroundcolor:'white' });   var filename = 'includes/homecontent.json';   var file = titanium.filesystem.getfile(titanium.filesystem.resourcesdirectory,   filename);      var preparsedata = (file.read().text);   var response = json.parse(preparsedata);   var content = response[0].content;  var webview = titanium.ui.createwebview({data:content});  var counter = 0;  webview.addeventlistener('load', function(e) {      counter++;         if ( counter > 1 ) {             self.remove(webview);             webview = null;             filename = 'includes/homecontent.json';               file = titanium.filesystem.getfile(titanium.filesystem.resourcesdirectory, filename);                  preparsedata = (file.read().text);               response = json.parse(preparsedata);               content = response[0].content;         }         var webview = titanium.ui.createwebview({data:content});             self.add(webview);         });  self.add(webview);  return self;  };   module.exports = homewindow; 

Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

jquery - Fancybox - apply a function to several elements -

An easy way to program an Android keyboard layout app -