M
M
Maxim2018-01-27 16:57:58
JavaScript
Maxim, 2018-01-27 16:57:58

How to fix "disabling" scripts when loading ajax tabs?

Hello.
I use the following code to load ajax tabs:

$('.tab-choice_item').click(function(){
        $('.tab-choice_item').removeClass('active');
        $(this).addClass('active');
        var href = $(this).attr('href')+ ' #tab-content';
        $('#tab-content').fadeTo(200, 0.10, loading);

        function loading(){
            $('#tab-content').load(href, '', function(){
                $('#tab-content').fadeTo(600, 1);
            })
        }
        return false;
    });


When switching tabs, all jquery functionality (slider, validation, etc.) disappears inside the switchable tab. When switching to the original tab, nothing works either.
What am I doing wrong?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
I'm Yoda, 2018-01-27
@Anadi

Try

$('body').on('click',  '.tab-choice_item', function(){
...
});

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question