<link href="https://gitcdn.github.io/bootstrap-toggle/2.2.2/css/bootstrap-toggle.min.css" rel="stylesheet">
<script src="https://gitcdn.github.io/bootstrap-toggle/2.2.2/js/bootstrap-toggle.min.js"></script>
と単純に使用してトグルスイッチを実装:
<input id="toggle-demo" type="checkbox" checked data-toggle="toggle">
<script type="text/javascript">
$(function() {
$('#toggle-demo').bootstrapToggle()
})
</script>
はまた、ここに私のバンドルの設定です:
public class BundleConfig
{
// For more information on bundling, visit http://go.microsoft.com/fwlink/?LinkId=301862
public static void RegisterBundles(BundleCollection bundles)
{
bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
"~/Scripts/jquery-{version}.js"));
bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
"~/Scripts/jquery.validate*"));
// Use the development version of Modernizr to develop with and learn from. Then, when you're
// ready for production, use the build tool at http://modernizr.com to pick only the tests you need.
bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
"~/Scripts/modernizr-*"));
bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
"~/Scripts/bootstrap.js",
"~/Scripts/respond.js"));
bundles.Add(new StyleBundle("~/Content/css").Include(
"~/Content/bootstrap.css",
"~/Content/site.css"));
}
}
しかし、それでもトグルスイッチではなく、チェックボックスとして表示されます。ありがとう:)
それは、コンソール上の任意のエラーを表示していますか? – mrid
@mrid nope、コンソールエラーはありません。 – James
は愚かな質問かもしれませんが、あなたはプラグインを初期化しましたか? – mrid