twitter-bootstrap-wizard icon indicating copy to clipboard operation
twitter-bootstrap-wizard copied to clipboard

cant add visited class to all li's before the current active li

Open rickyspires opened this issue 8 years ago • 6 comments

Hello.

I would like to add a visited class to all li's before the current active li but for some reason it will not work.

this is my code: $("#rootwizard").find("li.current").prevAll("li").addClass("visited");

any sugestions ?

rickyspires avatar Apr 21 '16 10:04 rickyspires

try $("#rootwizard").find("li.active").prevAll("li").addClass("visited");

nfer avatar May 02 '16 08:05 nfer

Not Working

$("#rootwizard").find("li.active").prevAll("li").addClass("visited");

Arunvelvj avatar May 04 '16 05:05 Arunvelvj

@Arunvelvj The code works fine in my project. As I think the syntax isn't wrong, so please check whether the $("#rootwizard"), $("#rootwizard").find("li.active"), $("#rootwizard").find("li.active").prevAll("li") returns the right objects.

Note: do not test it in the first tab, that means the prevAll is empty, try it in the second or the last tab.

nfer avatar May 04 '16 09:05 nfer

Hi,

$('#ap').bootstrapWizard({ 'onTabShow': function(tab, navigation, index) {
var $total = navigation.find('li').length - 1; var $current = index; var $percent = ($current/$total) * 100; $('#ap .progress-bar').css({width:$percent+'%'}); $("#ap").find("li.active").prevAll("li").addClass("visited"); }, onTabClick: function(tab, navigation, index) { return false; } });

Not Working.Help Me.

Arunvelvj avatar May 04 '16 12:05 Arunvelvj

@Arunvelvj use navigation.find("li.active").prevAll("li").addClass("visited"); but not $("#ap").find("li.active").prevAll("li").addClass("visited");.

I thins it's a typo error.

nfer avatar May 04 '16 14:05 nfer

$('#ap').bootstrapWizard({
    onTabShow: function(tab, navigation, index) {
        $("#ap").find("li.active").prevAll("li").addClass("visited");
    }
});

The problem with above code is that it takes into account the the previous "li" element and not the current one (the one you clicked).

A simple solution to this is to take into account the current "li" element. You can do that by replacing $("#ap").find("li.active") with tab. It will look something like this -

$('#ap').bootstrapWizard({
    onTabShow: function(tab, navigation, index) {
        tab.prevAll("li").addClass("visited");
    }
});

Hope it helps!

thewebsitedev avatar Aug 28 '16 23:08 thewebsitedev