Search code examples
javascripttitaniumtitanium-mobiletitanium-alloy

How to Hide/Show a text field in titanium alloy?


Is there any way to show/hide the text field based on the selected input. I have one radio button question is there If user select Other option from that question then I need to display one textbox to enter the value. Is it possible.

View

<TextField id="locationText" hintText="Enter Reason"></TextField>

Style:

"#locationText": {
    width: '90%',
    top: '25dp',
    height: 40
}

Controller:

button.addEventListener('singletap', function(e) {
      if(radioGroup.selectedValue == 'Other')
       {
        // Here I need to show the text field, If the selected value is not Other the text field should be hidden
       }
});

Any suggestions please


Solution

  • View :

    <TextField id="locationText" visible=false hintText="Enter Reason"></TextField>
    

    Controller :

    button.addEventListener('singletap', function(e) {
        if(radioGroup.selectedValue == 'Other'){ 
            $.locationText.visible = true;        
        }else{
            $.locationText.visible = false;
        }
    });