Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 引导无线电标签不适用于击倒_Javascript_Jquery_Css_Twitter Bootstrap_Knockout.js - Fatal编程技术网

Javascript 引导无线电标签不适用于击倒

Javascript 引导无线电标签不适用于击倒,javascript,jquery,css,twitter-bootstrap,knockout.js,Javascript,Jquery,Css,Twitter Bootstrap,Knockout.js,我尝试对选项卡使用引导单选按钮数据切换,我的DOM呈现是通过敲除实现的。该选项卡似乎无法在活动和非活动选项卡之间正确切换 以下是一个工作示例: 下面是如何重新创建问题(): 我在下面的图片中也描述了这个问题。有没有关于如何正确使用引导无线电标签的想法 您需要重新考虑您尝试使用的方法:以下是Ryan Niemeyer提出的一个漂亮的解决方案,您可以参考 您需要按照以下格式重写代码 var Section = function (name, selected) { this.name =

我尝试对选项卡使用引导单选按钮数据切换,我的DOM呈现是通过敲除实现的。该选项卡似乎无法在活动和非活动选项卡之间正确切换

以下是一个工作示例:

下面是如何重新创建问题():

我在下面的图片中也描述了这个问题。有没有关于如何正确使用引导无线电标签的想法


您需要重新考虑您尝试使用的方法:以下是Ryan Niemeyer提出的一个漂亮的解决方案,您可以参考

您需要按照以下格式重写代码

var Section = function (name, selected) {
    this.name = name;
    this.isSelected = ko.computed(function() {
       return this === selected();  
    }, this);
}

var ViewModel = function () {
    var self = this;

    self.selectedSection = ko.observable();

    self.sections = ko.observableArray([
        new Section('Section 1', self.selectedSection),
        new Section('Section 2', self.selectedSection),
        new Section('Section 3', self.selectedSection)
    ]);

    //inialize to the first section
    self.selectedSection(self.sections()[0]);
}

ko.applyBindings(new ViewModel());
var myObject = [{
 "first": "John",
    "interests": [ {"Description": "Reading"}, {"Description":"Mountain Biking"}, {"Description":"Hacking"} ]
},
{
 "first": "Boy",
    "interests": [ {"Description":"Reading"}, {"Description":"Mountain Biking"}, {"Description":"Hacking"} ]
}]
var koData ={
    arrayItems :ko.observableArray()
}

ko.mapping.fromJS(myObject, {}, koData.arrayItems);
ko.applyBindings(koData, $("#tabtest").get(0));
var Section = function (name, selected) {
    this.name = name;
    this.isSelected = ko.computed(function() {
       return this === selected();  
    }, this);
}

var ViewModel = function () {
    var self = this;

    self.selectedSection = ko.observable();

    self.sections = ko.observableArray([
        new Section('Section 1', self.selectedSection),
        new Section('Section 2', self.selectedSection),
        new Section('Section 3', self.selectedSection)
    ]);

    //inialize to the first section
    self.selectedSection(self.sections()[0]);
}

ko.applyBindings(new ViewModel());