Megaroeny
Megaroeny

Reputation: 827

Set tooltip dynamically for Ext.Net button

I wanted to set a tooltip dynamically, when two classes get toggled. I'm pretty new to Ext.Net and jQuery/Javascript and just trying to do some stuff on my own. This is what I have so far:

    if (DBA.mapFilterOn) {

        btnMapFilter.removeCls("icon-filter-off");
        btnMapFilter.addClass("icon-filter-on");
        btnMapFilter.toolTip("Filtering ON");
    } else {

        btnMapFilter.addCls("icon-filter-off");
        btnMapFilter.removeCls("icon-filter-on");
        btnMapFilter.toolTip("Filtering OFF");
    }

The classes toggle fine. I'm not sure how to get the Ext button tooltip to show through jQuery. The code above doesn't get it to show. I know how to do it through the aspx side though. Maybe I'm writing it wrong and jQuery?

Thanks so much for any help!

Upvotes: 0

Views: 627

Answers (2)

jansepke
jansepke

Reputation: 1979

there is setTooltip():

if (DBA.mapFilterOn) {
    btnMapFilter.removeCls("icon-filter-off");
    btnMapFilter.addClass("icon-filter-on");
    btnMapFilter.setTooltip({text: "Filtering ON"});
} else {
    btnMapFilter.addCls("icon-filter-off");
    btnMapFilter.removeCls("icon-filter-on");
    btnMapFilter.setTooltip({text: "Filtering OFF"});
}

Upvotes: 1

Felix
Felix

Reputation: 38102

Try to use .toggleClass():

if (DBA.mapFilterOn) {
    btnMapFilter.toggleClass("icon-filter-on icon-filter-off");
    btnMapFilter.toolTip("Filtering ON");
} else {
    btnMapFilter.toggleClass("icon-filter-on icon-filter-off");
    btnMapFilter.toolTip("Filtering OFF");
}

Upvotes: 0

Related Questions