【发布时间】:2020-03-15 17:10:20
【问题描述】:
我遵循了整个 Bootstrap Toggle 文档,但在我的 Laravel 6 刀片文件中,该操作仍然无法在 jQuery 中运行。
从 HTML 中删除 data-toggle="toggle",该操作有效。
看起来有些东西正在忽略或覆盖数据切换事件。
我已经尝试使用.toggle-event 来声明class="toggle-event",但也没有成功。
$(document).ready(function() {
$('#toggle-event').change(function() {
console.log(Date());
});
})
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css" integrity="sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/js/bootstrap4-toggle.min.js"></script>
<link href="https://cdn.jsdelivr.net/gh/gitbrent/bootstrap4-toggle@3.6.1/css/bootstrap4-toggle.min.css" rel="stylesheet"/>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js"></script>
<input id="toggle-event" type="checkbox" data-toggle="toggle" data-size="small" data-on="Enabled" data-off="Disabled" data-onstyle="success" data-offstyle="danger" data-id="1">
【问题讨论】:
标签: jquery bootstrap-4 toggle laravel-6