Loading fleet diagram in jquery tab browser does not completely fix the problem

There is a known issue with loading a graphics card in a jquery tab, which is not the initial tab here:

the following was set here: http://osdir.com/ml/jQuery/2009-06/msg02284.html

and answered this decision:

 .tabs-hide {
 /*display: none;*/
  position: absolute;
 left: -10000px;
 }

There are still some problems with this solution.

Suppose the name of the tab on which the fleet card is installed is called # tab-1. jquery tabs put this in the URL bar, so this will work initially at boot, but if you try to send someone the C # tab-1 URL (or any bookmark name in the url) in the link, the chart will not be visible. Has anyone seen a solution that always works, including the case where the tab may be in the url too.

+3
3

URL- # tab-1, , .

, , , (1):

$('#tabs_container').bind('tabsshow', function(event, ui) {
  if (ui.panel.id == "tab-1") {
    $.plot(...)
  }
})

'#tabs-container' 'tab-1' . 'tabsshow' - .

, , . , , . $.plot() .

(1): jQuery-ui docs

+1

css ...

.tab_content {
 display:block;
    visibility:hidden;
}

... (//HACK!!!...) jscript.js..

    $(document).ready(function() {
        //  When user clicks on tab, this code will be executed
        $("#tabs li").click(function() {
            //  First remove class "active" from currently active tab
        $("#tabs li").removeClass('active');

        //HACK!!! As the tabs_content HAS to initially be set to display:block in order for the flot graphs to be plotted correctly,
        // we need to manually change the visibility attribute for the tabs_content each time another tab is selected as active.
        //This assigns a variable to the tab_content of the currently active tab and changes the css visibility attribute to hidden.
            var old_tab = $("#tabs li").find("a").attr("href");
            $(old_tab).css('visibility', 'hidden');

            //  Now add class "active" to the selected/clicked tab
            $(this).addClass("active");

            //  Hide all tab content
            $(".tab_content").hide();

            //  Here we get the href value of the selected tab
            var selected_tab = $(this).find("a").attr("href");
//HACK!!! Change the css visibility attribute of the newly selected tab to visible
            $(selected_tab).css('visibility', 'visible');

            $(selected_tab).fadeIn();

            return false;
        });


});

... aspx ...

    <div id="tabs" >
                        <ul id="Ul1" >
                                <li class="active"><a href="#tab1">Main</a></li>
                                <li><a href="#tab2">tab2</a></li>
                                <li><a href="#tab3">tab3</a></li>
                                <li><a href="#tab4">tab4</a></li>
                                <li><a href="#tab5">tab5</a></li>
                            </ul>
         </div>

         <div style="width:100%;float:left;">     
                  <div id="tabs_content_container">

                           <div id="tab1" class="tab_content" style="visibility:visible">
                           content for tab 1
                            </div>
                            <div id="tab2" class="tab_content"  >
                             </div>
                  </div>
         </div>

... - !

+2

The main thing you need to remember is to place your js tabs right in front of the body tag.

-1
source

Source: https://habr.com/ru/post/1726832/


All Articles