This is a migrated thread and some comments may be shown as answers.

Get Tab when created dynamically

0 Answers 84 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Gary
Top achievements
Rank 1
Gary asked on 02 Dec 2012, 01:43 PM
UPDATE: Much easier using JQuery

var tabQuery = $('#workTabs  .k-tabstrip-items .k-item .k-link').filter(function () {
        return $(this).text() == tabName;
    });




I am creating Tabs dynamically and need to access the tab later to test if it already exists and add/change content.

I have a function to do this but it only works in IE and not firefox. There must be a better more JQuery way of doing it.
I have tried adding an ID field to the Tab when I create them and then using a selector but this dd not work. Any suggestions?
function findTab(tabs, tabName) {
    var i = 0;
    var foundTab;
    while (true) {
 
        var next = tabs.tabGroup.children("li").eq(i);
        if (next && next.length > 0) {
            var tabText = next[0].innerText;
            if (tabText == tabName) {
                // found
                foundTab = next;
                break;
            }
        }
        if (!next || (next.length == 0)) {
            break;
        }
        i++;
    }
 
    return foundTab;
}

No answers yet. Maybe you can help?

Tags
TabStrip
Asked by
Gary
Top achievements
Rank 1
Share this question
or