Titanium Community Questions & Answer Archive

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

Cancel Button For Text Area

I need to know how to get the cancel button to cancel what the user types into the text area. The text area will already have some text in it which is pulled from a database. However, the user will have the option to edit the text and save it to the server. I'm not the back-end guy, so I'm not really concerned with those details. I just need to know how to cancel the text the user just added.

Thanks!

— asked September 15th 2010 by Travis Moore
  • area
  • cancel
  • iphone
  • keyboard
  • mobile
  • text
0 Comments

3 Answers

  • var search = Titanium.UI.createSearchBar({
    barColor:'#000',
    showCancel:true,
    height:43,
    top:0,
    hintText:'search'
    });
    Titanium.UI.currentWindow.add(search);

    search.addEventListener('cancel', function(e)
    {
    Titanium.API.info('search bar cancel fired');
    search.blur();
    search.value="";
    });

    same as for createTextField

    — answered September 15th 2010 by Varun Atluri
    permalink
    0 Comments
  • Add a keyboardToolbar with the button you'd like, then add something like:

    close_button.addEventListener('click', function(e)
    {
       textarea.blur();
    });
    
    — answered September 15th 2010 by Colton Arabsky
    permalink
    0 Comments
  • Thanks for the comments guys. I ended up using:

    var paText = "Sample Text";
    
    cancel.addEventListener('click',function()
    {
       paAnnouncement.blur();
       paAnnouncement.value=paText;
    });
    

    That worked!

    I wasn't declaring the value in the text area as a variable, just as a hard coded value.

    — answered September 15th 2010 by Travis Moore
    permalink
    0 Comments
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.