3

オン/オフの切り替えには Bootstrap を使用しています。このページでは、ページ コンテンツをリロードするために 5 秒ごとに ajax が更新されます。私が直面している問題は、ページが ajax を介して更新されると、ブートストラップ スイッチがその CSS スタイルを失うことです。

私はfirefox inspectを使用していますが、これは私が見たものです:

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 をリロードするにはどうすればよいですか??

4

1 に答える 1

0

これを使っているとします

はいの場合、次のようなことができます

$.get(url, function(data) {
 $("#override").html(data);
 $(".make-switch").bootstrapSwitch(); //code to init the switch again
}
于 2015-07-03T08:26:16.700 に答える