Sparklines not drawing when using bootstrap and using tabs

烂漫一生 提交于 2019-12-05 02:06:40

问题


I got a RubyOnRails application (3.2.x) using bootstrap and jQuery Sparklines from http://omnipotent.net/jquery.sparkline/#s-about

My page has 2 tabs using bootstraps and looks as follows:

<%=javascript_include_tag "utilities/sparkline.js" %>

<script type="text/javascript">$(function() {$('.inlinesparkline').sparkline('html', {type: 'line', height: '20px', width: '100px'});});</script>

<ul class="nav nav-tabs" id="myTab">
    <li><a href="#tab1" data-toggle="pill">Tab1</a></li>
    <li class="active"><a href="#tab2" data-toggle="pill">Tab2</a></li>
</ul>

<div class="tab-content">
    <div class="tab-pane well" id="tab1">
        <span class="inlinesparkline">1,2,3,4,5,6,7,6,5,4,3,4,5,6,7,8,7,6,4</span>
    </div>
    <div class="tab-pane well active" id="tab2">
        Hi there
    </div>
</div>

If the second tab is the active tab then when switching to the first tab shows the numbers not the sparkline but if I make tab 1 the active tab then the sparkline is drawn.

How do I fix this?


回答1:


I finally fixed it, there is a parameter that you can add as an option:

disableHiddenCheck

had to set it to true, so this works with:

<script type="text/javascript">$(function() {$('.inlinesparkline').sparkline('html', {type: 'line', disableHiddenCheck: true, height: '20px', width: '100px'});});</script>


来源:https://stackoverflow.com/questions/13952354/sparklines-not-drawing-when-using-bootstrap-and-using-tabs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!