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

Reload tab every time it is clicked

5 Answers 2170 Views
TabStrip
This is a migrated thread and some comments may be shown as answers.
Jianwei
Top achievements
Rank 1
Jianwei asked on 17 Apr 2013, 06:14 PM
I know this question has been asked before, however, I didn't see a good answer for it.  Basically, I want my  tab to fire ajax call to get fresh content every time the tab is changed, not just the first time. Is there a configuration or recommended way that I can achieve this?

Jianwei

5 Answers, 1 is accepted

Sort by
0
Petur Subev
Telerik team
answered on 19 Apr 2013, 10:45 AM
Hello,

Did you try to achieve it through the reload method of the TabStrip?

var ts = $(tabstrip).data().kendoTabStrip;
ts.tabGroup.on('click','li',function(e){
     ts.reload($(this));
})

Kind regards,
Petur Subev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Josh
Top achievements
Rank 1
answered on 13 Apr 2015, 05:17 PM
I've tried this and it does work.  However now the first click executed the load twice.  Is there a way to determine if content has been loaded before calling reload?
0
Petur Subev
Telerik team
answered on 15 Apr 2015, 10:40 AM
Hello again,

What you can do to avoid multiple requests is to check if the content element is an empty one. Here is a runnable example:

http://dojo.telerik.com/@pesho/ehUne/2

Regards,
Petur Subev
Telerik
 
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
 
0
Josh
Top achievements
Rank 1
answered on 15 Apr 2015, 01:15 PM

Thanks.  I'll keep this in my back pocket.  I ended up with this which seems to work at the moment,

var tabStrip = $("#defaultMenuItems").data("kendoTabStrip");
for (var idx = 0; ; ++idx) {
    var tab = tabStrip.contentElement(idx);
    if (tab == null)
        break;
    if (tab == e.contentElement) {
        //current tab logic - just let it go
    }
    else {
        //all other tabs
        $(tab).html("");
    }
}

0
Josh
Top achievements
Rank 1
answered on 15 Apr 2015, 01:15 PM

Thanks.  I'll keep this in my back pocket.  I ended up with this which seems to work at the moment,

var tabStrip = $("#defaultMenuItems").data("kendoTabStrip");
for (var idx = 0; ; ++idx) {
    var tab = tabStrip.contentElement(idx);
    if (tab == null)
        break;
    if (tab == e.contentElement) {
        //current tab logic - just let it go
    }
    else {
        //all other tabs
        $(tab).html("");
    }
}

Tags
TabStrip
Asked by
Jianwei
Top achievements
Rank 1
Answers by
Petur Subev
Telerik team
Josh
Top achievements
Rank 1
Share this question
or