【发布时间】:2015-10-28 11:58:37
【问题描述】:
很难让我的淘汰单选按钮绑定与引导水平单选按钮组一起使用。
这是小提琴。
http://jsfiddle.net/LkqTU/27489/
这里是代码。
<h3>Works When I don't use the button groups</h3>
<input type="radio" name="processingType" value="Partial" data-bind="checked: ProcessingChoice" /> Partial
<input type="radio" name="processingType" value="Total" data-bind="checked: ProcessingChoice" /> Total
<input type="radio" name="processingType" value="OverUnder" data-bind="checked: ProcessingChoice" /> Over Under
<p>
<br>The Choice is <strong><span data-bind="text: ProcessingChoice"></span></strong>
<hr>
<h3>With Button Groups not so much</h3>
<div class="btn-group" data-toggle="buttons">
<label class="btn btn-default">
<input type="radio" name="BootstrapprocessingType" value="Partial" autocomplete="off" data-bind="checked: BootstrapProcessingChoice">Partial</label>
<label class="btn btn-default">
<input type="radio" name="BootstrapprocessingType" value="Total" autocomplete="off" data-bind="checked: BootstrapProcessingChoice">Total</label>
<label class="btn btn-default">
<input type="radio" name="BootstrapprocessingType" value="Over Under" autocomplete="off" data-bind="checked: BootstrapProcessingChoice">OverUnder</label>
</div>
<div> <br>The Bootstrap Choice is <span data-bind="text: BootstrapProcessingChoice"></span></div>
这是视图模型
var ViewModel = function () {
this.ProcessingChoice = ko.observable("Total");
this.BootstrapProcessingChoice = ko.observable("Total");
};
ko.applyBindings(new ViewModel());
【问题讨论】:
-
嗯,这绝对是个问题,但是 SO 中有帖子解决了这个问题。
data-toggle="buttons"导致问题在此处检查 jsfiddle.net/LkqTU/27490 但为了使其正常工作,请检查此帖子 stackoverflow.com/questions/20077475/… 。
标签: twitter-bootstrap knockout.js