Bootstrap radio button group knockout binding doesn#39;t work(Bootstrap 单选按钮组敲除绑定不起作用)
问题描述
I followed this: http://volaresystems.com/blog/post/2013/12/09/Using-Bootstrap-3-radio-button-groups-with-Knockout-3-data-bindings (jQuery 2.0.3, Bootstrap 3.0.3, Knockout 3.0.0)
As far as I can see the only differences are the jQuery, Knockout and Bootstrap version numbers, but the major version numbers match. http://jsfiddle.net/csabatoth/rLtL16xk/12/ (jQuery 2.1.3, Bootstrap 3.3.4, Knockout 3.3.0)
<p>
Currently selected: <span data-bind="text: selectedOption"></span>
</p>
<div class="btn-group-vertical" data-toggle="buttons">
<label class="btn btn-lg btn-primary" data-bind="css: { 'active': selectedOption() === 'Purchase Target Cat' }">
<input type="radio" name="options" id="option1" data-bind="checked: selectedOption, checkedValue: 'Purchase Target Cat'">Purchase Target Cat
</label>
<label class="btn btn-lg btn-primary" data-bind="css: { 'active': selectedOption() === 'Purchase Existing Cat' }">
<input type="radio" name="options" id="option2" data-bind="checked: selectedOption, checkedValue: 'Purchase Existing Cat'">Purchase Existing Cat
</label>
<label class="btn btn-lg btn-primary" data-bind="css: { 'active': selectedOption() === 'Existing Dog Purchases Target Cat' }">
<input type="radio" name="options" id="option3" data-bind="checked: selectedOption, checkedValue: 'Existing Company Purchases Target Company'">Existing Dog Purchases Target Cat
</label>
</div>
var viewModel = function () {
var self = this;
self.selectedOption = ko.observable("Target Cat");
}
$(document).ready(function () {
var vm = new viewModel();
ko.applyBindings(vm);
});
Can anyone point out why this doesn't work? The binding is only one way. It gets the initial value, but not useful further.
try
<div class="btn-group-vertical" data-toggle="buttons"> remove data-toggle="buttons"
add css:
label.btn > input[type='radio']
{
display: none;
}
js: remove $(document).ready(function () {
DEMO
这篇关于Bootstrap 单选按钮组敲除绑定不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Bootstrap 单选按钮组敲除绑定不起作用
基础教程推荐
- 为什么我在 Vue.js 中得到 ERR_CONNECTION_TIMED_OUT? 2022-01-01
- 每次设置弹出窗口的焦点 2022-01-01
- 如何在特定日期之前获取消息? 2022-01-01
- jQuery File Upload - 如何识别所有文件何时上传 2022-01-01
- 如何使用 CSS 显示和隐藏 div? 2022-01-01
- 什么是不使用 jQuery 的经验技术原因? 2022-01-01
- WatchKit 支持 html 吗?有没有像 UIWebview 这样的控制器? 2022-01-01
- Node.js 有没有好的索引/搜索引擎? 2022-01-01
- Javascript 在多个元素上单击事件侦听器并获取目标 2022-01-01
- 如何使用sencha Touch2在单页中显示列表和其他标签 2022-01-01
