1

I have a really simple line of code. I have a tabstrip provided by Kendo library

i = 0;
x = 10;
while (i < x) {
    var tabStrip = $("#myId").data("kendoTabStrip");
    tabStrip.select(i);
    i++;
}

When I go step by step using debugger everything is ok - tabStrip.select(i) method is being invoked and works perfectly. But when I run it without debugger it just behaves like there was no this line. I do not understand why, and I don't know how to solve this. (i and x variables are just sample variables, maybe the information that the method is invoked inside the while loop is important)

var tabGroupObject = $("<div>").attr("id", "myId")
tabGroupObject = $(tabGroupObject).kendoTabStrip({
    animation: {
        open: {
            effects: "fadeIn"
        }
    }
});
var tabStrip = tabGroupObject.data("kendoTabStrip");
6
  • 4
    And what do you expect to see? I mean obviously it will only select 9, and that's all.
    – dfsq
    Nov 12, 2015 at 20:33
  • @dfsq yes but the problem is it just doesn't select anything. Like at all
    – Tomek
    Nov 12, 2015 at 20:34
  • you need to include browser/OS you are using
    – 2174714
    Nov 12, 2015 at 20:35
  • Provide HTML code and how you set up tabStrip. Or better kendo fiddle.
    – dfsq
    Nov 12, 2015 at 20:36
  • 1
    You should show a piece of code that makes more sense. Calling select(i) from 0-9 will leave the last one as selected and makes the previous calls obsolete. Nov 12, 2015 at 20:44

2 Answers 2

1

Seems to be a synchronization issue, very common in JavaScript when dealing with Ajax calls or DOM modifications. That's why it works when you execute the code step by step giving enough time for the actions to happen.

My recommendation would be to read a little about Async JavaScript and try to implement a callback function that triggers once the animation finish its task.

2
  • This should be a comment Nov 12, 2015 at 20:58
  • @JuanMendes post the answer, don't hold yourself Nov 13, 2015 at 3:11
1

Assumption:- I'm assuming you are looking for an ajax trigger event which gets fired in the browser in response to the select of the tabScript.
Solution:- If that's the case please know that browsers combines all the ajax events on an element within a set amount of time into one event to reduce the number of unwanted post calls, what you can do is try adding a delay if you want these events to be called else it would simply trigger the even which gets called on the tabSctrip.select(9) as mentioned by dfsq.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.