【问题标题】:Bootstrap css not working after ajax refreshajax刷新后Bootstrap css不起作用
【发布时间】:2015-06-15 08:18:10
【问题描述】:

我正在使用 Bootstrap 进行开/关切换。在此页面中,它每 5 秒刷新一次 ajax 以重新加载页面内容。我面临的问题是当通过 ajax 刷新页面时,引导开关失去了它的 css 样式。

我使用 Firefox 检查,这就是我所看到的:

ajax 刷新前:

<div id="override">
.....
    <div class="margin-bottom-10">  <label for="option1"></label>  <div class="bootstrap-switch bootstrap-switch-wrapper bootstrap-switch-on bootstrap-switch-small bootstrap-switch-animate bootstrap-switch-id-1234>
                <div class="botstrap-switch-container">
                  <span class="bootstrap-switch-handle-on bootstrap-switch-primary">On</span>
                  <label class="bootstrap-switch-label" for="1234"></label>
                  <span class="bootstrap-switch-handle-off bootstrap-switch-default">Off</span>
                  <input id="1234" name="radio1" class="make-switch" data-size="small" checked="" type="checkbox">
        </div>
        </div>
        </div>
......
</div>

ajax 刷新后:

    <div id="override">
    .....
        <div class="margin-bottom-10">  
          <label for="option1"></label>
          <input id="1234" name="radio1" class="make-switch" data-size="small" checked="" type="checkbox">
        </div>
..........
    </div>

ajax 代码:

$.get(url, function(data) {
  $("#override").html(data);
}

我如何重新加载那些必要的引导 css 甚至 js ??

【问题讨论】:

    标签: twitter-bootstrap bootstrap-switch


    【解决方案1】:

    我假设你正在使用this

    如果是,你可以做类似的事情

    $.get(url, function(data) {
     $("#override").html(data);
     $(".make-switch").bootstrapSwitch(); //code to init the switch again
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-09-13
      • 1970-01-01
      • 2011-07-29
      • 1970-01-01
      • 1970-01-01
      • 2017-04-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多