Calling events from webview - event not being called on webview.reload()

You must Login before you can answer or comment on any questions.

I'm using the latest version of the SDK and yet this doesn't seem to work.

In my results.js file:

var webview = Ti.UI.createWebView({url:'page.htm'});
win.add(webview);
 
Ti.App.addEventListener('getData', function(){
    alert('fired');
});
In page.htm:
<html>
    <head>
 
        alert('webview loaded');
        Ti.App.fireEvent('getData');
 
    </head>
    <body></body>
</html>
The first time results.js loads the webview alerts "webview loaded" and then calls the event getData. However on calling webview.reload() the webview alerts "webview loaded", but the fireEvent doesn't fire/get through.

I've even tried re-setting the Ti.App.addEventListener before reloading the webview.... I don't know what else to do.

Thank you.

1 Answer

Accepted Answer

How about if you reset the (same) url rather than using the reload method?

You could also try adding a random number param to the page.htm?rand=12345 too.

Interested to know how this works out.

btw: iPhone or Android?

— answered 2 years ago by Kosso .
answer permalink
5 Comments
  • atm iPhone - but only beacause the android simulator has a problem with webviews and sending events, so am only testing in iphone till its at a point I can put it on my phone to test (motorola milestone)

    — commented 2 years ago by Thomas Clayson

  • OK. iPhone good. Have you tried the suggestions above?

    — commented 2 years ago by Kosso .

  • Yes, it works perfectly on iphone, just loading onto my phone to check android. :)

    — commented 2 years ago by Thomas Clayson

  • Show 2 more comments

Your Answer

Think you can help? Login to answer this question!