【发布时间】:2016-12-23 01:00:14
【问题描述】:
我正在尝试使用http://www.bootstraptoggle.com/ 实现拨动开关
我已将以下内容添加到我的页面中:
<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 nope,没有控制台错误。
-
可能是个愚蠢的问题,但你确实初始化了插件,对吧?
-
@mrid 你到底是什么意思?
-
@mrid 谢谢你 - 你让我意识到 jquery 并没有因为脚本渲染的一些奇怪原因被选中,我现在已经解决了这个问题 :)
标签: html twitter-bootstrap checkbox twitter-bootstrap-3