O'Reilly logo

Appcelerator Titanium Smartphone App Development Cookbook - Second Edition by Jason Kneen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Passing event data between your app and a Webview using custom events

So, while we can use the events built into the Titanium API and these will suit 90% of our general purposes, what happens when we want to launch an event that's not covered by one of the standard Titanium components? Luckily for us, Titanium already has it covered with the fireEvent method in our Ti.App namespace!

The fireEvent allows you to execute an arbitrary event with an event listener name that you determine, and then listen for that event in your code. In this recipe, we are going to get a little tricky and write code that copies an input field's data and displays it on a label back in our app. We will do this by firing a custom event from within a Webview, which we'll ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required