Created
October 1, 2014 20:13
-
-
Save pegli/30ea3b3b29bcb5ff104a to your computer and use it in GitHub Desktop.
Ti webview eventing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var win = Ti.UI.createWindow(); | |
var webview = Ti.UI.createWebView({ | |
url: 'local.html' | |
}); | |
var button = Ti.UI.createButton({ | |
title: 'fromTitanium', | |
height: '50dp', | |
width: '130dp' | |
}); | |
button.addEventListener('click', function(e) { | |
Ti.App.fireEvent('app:fromTitanium', { message: 'event fired from Titanium, handled in WebView' }); | |
}); | |
Ti.App.addEventListener('app:fromWebView', function(e) { | |
alert(e.message); | |
}); | |
win.add(webview); | |
win.add(button); | |
win.open(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<script> | |
Ti.App.addEventListener("app:fromTitanium", function(e) { | |
alert(e.message); | |
}); | |
</script> | |
</head> | |
<body> | |
<button onclick="Ti.App.fireEvent('app:fromWebView', { message: 'event fired from WebView, handled in Titanium' });">fromWebView</button> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment