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 then listen for and respond to in our Titanium window!