Skip to content

Instantly share code, notes, and snippets.

@csemrm
Last active August 29, 2015 14:00
Show Gist options
  • Save csemrm/11367991 to your computer and use it in GitHub Desktop.
Save csemrm/11367991 to your computer and use it in GitHub Desktop.
custom alert button for IOS and Android
var args = arguments[0] || {};
var buttonNames = args.buttonNames;
$.dialog.buttonNames = buttonNames;
function doClick(e) {
alert('You clciked on ' + buttonNames[e.index]);
};
$.dialog.show();
<Alloy>
<AlertDialog id="dialog" onClick="doClick" title="AlertDialog"
message="AlertDialog"></AlertDialog>
</Alloy>
/*
Hi,
Thanks for writing us. Here, I have added sample code link for custom Alert dialog with click Event Listener using Titanium.UI.AlertDialog.
In my sample code, dynamically assign button name from array and I also add click event listener in alert dialog. Click event return button index when user click on alert dialog button. Then we call easily check which button clicked by user.
Please check this sample code I hope it will help to fixing your problem.
https://gist.github.com/csemrm/11367991
Let me know if you have any further question about this issues.
Thanks
*/
$.win.open();
var buttonNames = ['confirm', 'help', 'cancel'];
function showDialog() {
var dialog = Alloy.createController('alertdialog', {
buttonNames : buttonNames,
});
};
<Alloy>
<Window id="win" title="Click window to test" backgroundColor="white"
exitOnClose="true" fullscreen="false" >
<Button title="Show Dialog" onClick="showDialog" ></Button>
</Window>
</Alloy>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment