Last active
August 29, 2015 14:00
-
-
Save csemrm/11367991 to your computer and use it in GitHub Desktop.
custom alert button for IOS and Android
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var args = arguments[0] || {}; | |
var buttonNames = args.buttonNames; | |
$.dialog.buttonNames = buttonNames; | |
function doClick(e) { | |
alert('You clciked on ' + buttonNames[e.index]); | |
}; | |
$.dialog.show(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<Alloy> | |
<AlertDialog id="dialog" onClick="doClick" title="AlertDialog" | |
message="AlertDialog"></AlertDialog> | |
</Alloy> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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, | |
}); | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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