javascriptwinjspivotitem

WinJS.UI.PivotItem: How can I check which one is active?


Probably a simple question for some of you... but since this is a pre made solution that was given to me to fix, I need a little help over here...

I need to see, each 500 mls, which is the active pivot item, so I can make some logic on the navigation...

so, I started by calling a function in my Functions.js startLooping();

Then I defined it:

function startLooping() {
    if (interval > 0) {
        clearInterval(interval);
    }
    interval = setInterval("doChecking()", iFrequency);
}

Now I have the Pivot Items loaded dynamically in another file (MenuNav.js)

for (var i = 0; i < options.length ; i++) {
    var menuItem = options[i];
    menuItem.showBanner = (i == 0);
    var element;
    if (menuItem.childrenCount > 0) {
        element = loadSectionsPage(menuItem, showAtTheEndHandler);
    } else {
        element = loadMoviesListing(menuItem);
    }
    var pivotItem = new WinJS.UI.PivotItem(element, { header: menuItem.text });
    pivot.items.push(pivotItem);
}

And these headers are going to be (from API) Action, Anime, Sci Fi, etc

How do I do the function doChecking() to check which is the active PivotItem? (I guess it has to be with the pivot.selectedItem property, but I am not sure on how to use it)


Solution

  • I would start by debugging the act while it is active.

    I'm willing to bet that there is a CSS style applied to the active item in the list. Make a note of what that CSS class is called.

    Now in your JavaScript code, check to see which item in HTML has that class applied. That's your active item.