Skip to content

Instantly share code, notes, and snippets.

@jonalter
Created March 18, 2011 22:18
Show Gist options
  • Save jonalter/876954 to your computer and use it in GitHub Desktop.
Save jonalter/876954 to your computer and use it in GitHub Desktop.
Programmatic way to close an alert
// Open an existing window
window.open();
// Create the alert dialog popup
var popup = Ti.UI.createAlertDialog({
title: "Confirm Purchase?",
buttonNames: ["Yes", "No"],
cancel: 1
});
// Wait a couple of seconds to pop up the alert
setTimeout(function() {
// Show the alert dialog
popup.show();
// Add an event listener that closes the popup
Ti.App.addEventListener("closeAlert", function(e) {
// Hide the popup
popup.hide();
});
// Wait 2 more seconds, fire the event
setTimeout(function() {
Ti.App.fireEvent("closeAlert", { test: "data" });
}, 2000);
}, 2000);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment