Timeline step forward and step back

35
December 01, 2019, at 4:30 PM

I am doing a simple form with a few steps. I am using a custom timeline to go forward and backward between different steps. At this moment I can only go forward but when I am trying to go backward it returns me null.

This is my javascript code for the timeline. Only works when I go to the next step.

    // click on timeline steps
    $('.stage.current, .go_back').click(function(){
        if (typeof($(this).data('target')) != "undefined") {
            $('form#calculator')
                .prop('action', base.url_lang + $(this).data('target'))
                .submit();
                console.log($(this).eq(-2).data('target'));
        }
    });
    if (typeof history.pushState === "function") {
        history.pushState({}, null, null);
        window.onpopstate = function () {
            // Forward step
            if ($('form#calculator').length >= 1){
                $('form#calculator')
                    .prop('action', base.url_lang + $('.stage.current').eq(-2).data('target'))
                    .submit();
                history.pushState({}, null, null);
            }else{
                window.history.back();
            }
            // Backward step
            if ($('form#calculator').length >= 1){
                $('form#calculator')
                    .prop('action', base.url_lang + $('.go_back').eq(-2).data('target'))
                    .submit();
                history.back({}, null, null);
            }else{ 
                window.history.back();
            }
        };
    }
READ ALSO
Why videojs progress bar is not staying fixed

Why videojs progress bar is not staying fixed

i have problem with videojs progress barit is not staying fixed

48
How to scrape data from following html using querySelector or jQuery

How to scrape data from following html using querySelector or jQuery

I want to get text from this html using querySelector or jQuery

40
How to add element div before text (How to append text within an element)

How to add element div before text (How to append text within an element)

Hello I have a element <a href='#'>whatsapp-300</a> and i want select before this mark - and make it like this <i class='fa fa-whatsapp'></i> knowing that the word whatsapp is not fixed and can be facebook and othersi want a way to do this either...

66
Why the name of my &lt;a&gt; is not changing with the for loop?

Why the name of my <a> is not changing with the for loop?

I'm working with django and I need to create dynamically some links <a>My code is,

37