Skip to content

Instantly share code, notes, and snippets.

@grantges
Created July 19, 2013 15:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grantges/e979dbbf0b817b0d2156 to your computer and use it in GitHub Desktop.
Save grantges/e979dbbf0b817b0d2156 to your computer and use it in GitHub Desktop.
Android WebView not capturing Events - Example (TI SDK 3.1.1.GA)
<html>
<head>
<script>
Ti.App.addEventListener("updatePage", function(e){
Ti.API.info("captured event: "+e.text);
updateText(e.text)
})
function updateText(t){
var div = document.getElementById('myDiv');
div.innerHTML = text;
}
</script>
</head>
<body>
Android Test
<div id="myDiv"></div>
</body>
</html>
$.webView.addEventListener('load', function(e){
Ti.API.info("page loaded");
Ti.App.fireEvent("updatePage", {text:"Hello WebView"});
Ti.API.info('event fired');
setTimeout(function(){
$.webView.evalJS('updateText("Hello WebView from EvalJS")');
}, 2000)
});
$.webView.url ="/index.html"
$.index.open();
"#webView":{
height: Ti.UI.FILL,
width: Ti.UI.FILL,
}
<Alloy>
<Window class="container">
<WebView id="webView" />
</Window>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment