Titanium Community Questions & Answer Archive

We felt that 6+ years of knowledge should not die so this is the Titanium Community Questions & Answer Archive

Bug or Doc Error: AlertDialog click event properties

Hey all. just posting something I noticed today.

a.addEventListener('click', function(e)
{
    Ti.API.info(e.cancel);
});

in the docs, the "cancel" property is said to be "boolean to indicate if the cancel button was pressed". But it returns the index for the cancel button instead. Just a heads up.

— asked November 23rd 2010 by Dave F
  • alertdialog
  • cancel
0 Comments

5 Answers

  • To bring attention to this again, this still seems to be a problem in 1.7.2.

    You can illustrate the issue by making the cancel button index 0. When you test e.cancel, it will return '0', and since 0 is falsey, something like if(e.cancel) doesn't work, because it never returns true.

    — answered October 7th 2011 by Shauna Gordon
    permalink
    0 Comments
  • Just for attention. It's still there in 1.7.5.

    — answered December 4th 2011 by Takashi Kawachi
    permalink
    0 Comments
  • Just noticed the same problem. I'm not sure if the documentation or the implementation is wrong. I guess I'll have to just check a magic index property for now :(

    — answered February 24th 2011 by Damien Bargiacchi
    permalink
    0 Comments
  • Complete Solution provided here.

    http://developer.appcelerator.com/question/87471/alertdialog-actions

    — answered February 29th 2012 by AvtarSingh Suchariya
    permalink
    1 Comment
    • This question isn't about what to do with what buttons are pressed (as your link does), but rather that there is a discrepancy between the docs and the actual value for "e.cancel". The docs say that it's a boolean, but in actuality, it's the cancel button's index (so, if your cancel button has an index of 0, something like "if(e.cancel)" will never fire, even if the cancel button was pressed).

      — commented March 12th 2012 by Shauna Gordon
The ownership of individual contributions to this community generated content is retained by the authors of their contributions.
All trademarks remain the property of the respective owner.