Search code examples
sencha-touch-2

Setting panel attributes dynamically in Sencha Touch 2


In Sencha touch 2, how can I set the value of a attribute ( like the html one) using a function?

Example:

    {
        xtype: 'panel',
        html: function () {
            if (conditionA) return 2
            return 4
        }
    }

Any ideas?


Solution

  • Using a self-executing anonymous function:

    {
        xtype: 'panel',
        html: (function () {
            if (0) {
                return 'lol';
            }
            return 'rofl';
        })()
    }