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

Reference to TabStrip Using JQuery

4 Answers 97 Views
TabStrip (Mobile)
This is a migrated thread and some comments may be shown as answers.
Jay
Top achievements
Rank 1
Jay asked on 13 Jan 2014, 12:52 PM
I'm encountering problems retrieving my app's tab strip using JQuery. Sometimes it works, sometimes it doesn't. Code snippet below:

function updateBadges() {
        console.log("Updating badges");
        var tabstrip = $("#tabstrip").data("kendoMobileTabStrip");
        if (tabstrip) {
            var reminderCount = getRemindersDataSource().view().length;
            console.log(reminderCount);
            if (reminderCount > 0)
                tabstrip.badge(2, reminderCount);
            else
                tabstrip.badge(2, false);
        } else {
            console.log("Can't find tabstrip");
        }
    }

Tabstrip is defined as:

<div id="tabstrip" data-role="tabstrip">
etc

Are there any constraints to be followed?

Thanks.

4 Answers, 1 is accepted

Sort by
0
Kamen Bundev
Telerik team
answered on 14 Jan 2014, 07:15 AM
Hi Jay,

Your code looks okay, there must be something else at work in your case. Can you share some more code, like when do you update the badges or maybe try to reproduce the issue in a jsBin and send it over?

Regards,
Kamen Bundev
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Jay
Top achievements
Rank 1
answered on 14 Jan 2014, 02:34 PM
I'll see if I can replicate in JsBin.

Meanwhile I read the following thread: http://www.kendoui.com/forums/kendo-ui-mobile/tabstrip/can't-select-tabstrip-badge-and-update-it-.aspx. I followed answer recommendation and moved code snippet to view class and updated reference from:
var tabstrip = $("#tabstrip").data("kendoMobileTabStrip");
to:
var tabstrip = e.sender.view().footer.find(".km-tabstrip").data("kendoMobileTabStrip");

This worked. However, I need the snippet to be user-action-independent and view-independent thus I've placed it outside a view class (it's called on change of data source). Is there any more general or alternate way to get a reference?

Thanks.
0
Jay
Top achievements
Rank 1
answered on 14 Jan 2014, 03:57 PM
Please see JsBin http://jsbin.com/ImiyUHas/2/edit. Unable to get a reference using #tabstrip when at other than the first tab.

Thanks.
0
Accepted
Jay
Top achievements
Rank 1
answered on 15 Jan 2014, 05:44 AM
Refactored and put everything in their proper places. Thanks.
Tags
TabStrip (Mobile)
Asked by
Jay
Top achievements
Rank 1
Answers by
Kamen Bundev
Telerik team
Jay
Top achievements
Rank 1
Share this question
or