Search code examples
javascriptcssjscrollpanejquery-jscrollpane

jScrollPane Vertical Tabs - How can I simulate a click on a link/tab?


I've implemented with success a Vertical jScrollPane with tabs I'm trying to make a tab show up by default.

Can I do this by simulating a click on the link with the id #default ? If so, how?

The code is identical to the on that site. Here's the javascript:

   $(function()
{
    // Create the "tabs"
    $('.tabs').each(
        function()
        {
            var currentTab, ul = $(this);
            $(this).find('a').each(
                function(i)
                {
                    var a = $(this).bind(
                        'click',
                        function()
                        {
                            if (currentTab) {
                                ul.find('a.active').removeClass('active');
                                $(currentTab).hide();
                            }
                            currentTab = $(this).addClass('active')
                                            .attr('href');
                            $(currentTab).show().jScrollPane();
                            return false;
                        }
                    );
                    $(a.attr('href')).hide();
                }
            );
        }
    );
});

Here's the html code:

        <ul class="tabs"> 
            <li><a href="#pane1" id="default">Pane 1</a></li> 
            <li><a href="#pane2">Pane 2</a></li> 
            <li><a href="#pane3">Pane 3</a></li> 
        </ul> 

Thank you!


Solution

  • Does this not work as expected, after it's initialized?

    $('#default').click()