0
votes

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!

2
what exactly is btnMapFilter a jQuery object or an ExtJS component (which one?)Jan S
It's actually an Ext buttonjaminroe

2 Answers

1
votes

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"});
}
0
votes

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");
}