javascriptcolorstitaniumappceleratortitanium-alloy

How to change border color of a view dynamically in Titanium


I am new to Titanium and I am trying to change the border color of a view through my .js file.

XML File

<View id="container" autoStyle="true" />

TSS File

#container: {
    top: '5dp',
    height: '50dp',
    left: '20dp',
    right: '20dp',
    borderWidth: '1dp',
    borderColor: 'blue'
}

.redBorder: {
    borderColor: 'red'
}

.js File

$.addClass($.container, "redBorder");

Please let me know how to achieve this.


Solution

  • You can just set property right away:

    $.container.borderColor = 'red';
    

    And that's it.