Advertisement
Guest User

Untitled

a guest
Nov 21st, 2014
221
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. app.js:
  2.  
  3. var win = Ti.UI.createWindow({
  4.     title: "Test",
  5.     navBarHidden: false
  6. });
  7.  
  8. var view = Ti.UI.createWebView({
  9.     url: "test.html"
  10. });
  11.  
  12. win.add(view);
  13.  
  14. win.addEventListener('open', function(e) {
  15.     win.activity.invalidateOptionsMenu();
  16.     var actionBar = win.activity.actionBar;
  17.     actionBar.title = win.title;
  18.     actionBar.displayHomeAsUp = true;
  19.     actionBar.onHomeIconItemSelected = function() {
  20.         win.fireEvent('mytest');
  21.     };
  22. });
  23.  
  24. win.addEventListener('mytest', function() {
  25.     Ti.API.info("'mytest'");
  26.     view.evalJS("doTest()");
  27. });
  28.  
  29. win.open();
  30.  
  31.  
  32. test.html:
  33.  
  34. <html>
  35. <head>
  36. <script type="text/javascript" src="test.js"></script>
  37. </head>
  38. <body>
  39. Tap the ActionBar back arrow.
  40. </body>
  41. </html>
  42.  
  43.  
  44. test.js:
  45.  
  46. function doTest()
  47. {
  48.     Ti.API.info("doTest()");
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement