简体   繁体   中英

Remove class during orientation change in sencha touch 2

I want to remove class during orientation change

View.js

  itemCls: 'dataview-item',
            itemTpl: [
                '<div class="arHeadline">',
                '    {Headline}',
                '</div>',
                '<div class="arbyline">',
                '    {Author}',
                '</div>',
                '<div class="arcontent">',
                '    {Content}',
                '</div>',
                '<div id="myline"class="ardrawline">',
                '</div>'

            ],

Controller.js

orientationChangeHandler : function(viewport,orientation,width,height){
    var domEl1 = Ext.get('myline');
    console.log("els "+domEl1);

    if (orientation === "landscape") {
        domEl1.addCls('ardrawline');
    } else {
        domEl1.removeCls('ardrawline');
    }
}

Do not use the same IDs for each item -> id="myline"

For example you can define your template:

<div data-type="myline" class="ardrawline">

and then you can select your elements as follow:

Ext.DomQuery.select("div[@data-type='myline']");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM