Hi, I am trying to create an hybrid app using Alloy and jquery mobile and I am facing an issue.
Issue: I am not able to send events/data to a webview which has jquery mobile where as I am able to send events from webview to Alloy. If I comment out the jquery mobile tag, then it works as expected. Please refer the code below for more info.
index.js (controller)
$.mywebview.setUrl(Ti.Filesystem.resourcesDirectory+'web/index.html'); $.index.open(); Ti.App.addEventListener("app:fromWebView",function(e){ Ti.API.info(e.message); Ti.App.fireEvent("app:fromAlloy",{message:"Hello from Alloy"}); });
index.xml(Alloy view)
<Alloy> <Window class="container"> <WebView top="30dp" id="mywebview"></WebView> </Window> </Alloy>
index.html(my webview)
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jquerymobile/1.4.3/jquery.mobile.min.js"></script>
<script type="text/javascript">
function sendMsg(){
Ti.App.fireEvent("app:fromWebView",{message:"Hello from webview"});
}
Ti.App.addEventListener("app:fromAlloy",function(e){
alert(e.message);
});
</script>
</head>
<body>
<button onclick="sendMsg();">Hello</button>
</body>
</html>
Details
1.Titanium SDK: 3.4.1GA 2.Target Platform: Android 4.4.4 3.Device: Moto G 4.Titanium Studio : Titanium Studio, build: 3.4.1.201410281727 (c) Copyright 2012-2014 by Appcelerator, Inc. All rights reserved. Build: jenkins-titanium-rcp-master-202 (origin/master) Date: 28 October 2014, 17:28:23