如何在敲除中添加静态链接元素作为Javascript中的下拉列表项元素

如何在敲除中添加静态链接元素作为Javascript中的下拉列表项元素,javascript,html,css,knockout.js,Javascript,Html,Css,Knockout.js,我用的是击倒JS 并且,该需求表示“在下拉列表中,我需要显示从服务动态获取的一些数据 但是,当下拉列表展开时,一个名为“createnew”的链接也应该作为下拉列表中的最后一个列表项追加。” 要在下拉列表中获取列表项,我使用 this.intGroups = ko.observableArray([]); 以及 此代码获取并绑定下拉列表中的所有“组名” 但是html看起来像: <div class="form-group">

我用的是击倒JS

并且,该需求表示“在下拉列表中,我需要显示从服务动态获取的一些数据

但是,当下拉列表展开时,一个名为“createnew”的链接也应该作为下拉列表中的最后一个列表项追加。”

要在下拉列表中获取列表项,我使用

this.intGroups = ko.observableArray([]);
以及

此代码获取并绑定下拉列表中的所有“组名”

但是html看起来像:

                      <div class="form-group">
                        <label class="control-label">Groups</label>
                        <select size="3" name="intGroup1" id="intGroup1" class="form-control" tabindex="10" data-bind="options: $root.intGroups, optionsText: 'Name', optionsValue: 'Id',optionsCaption: '--Select--',value:$data.IntGroupName"></select>

                        <a href="#" class="ispicon ispicon_plus" data-toggle="modal" data-target="#addSchedule" data-bind="click:$parent.addGroup" title="Create New">Create New</a>

                    </div>
现在只需要将此
创建新的
作为下拉列表项的一部分

怎么做


提前感谢。

您可以从计算的可观测数据生成下拉选项-

获取选项列表,并在末尾附加额外选项:

this.intGroups = ko.observableArray([]);
this.dropdownOptions = ko.pureComputed(function() {
    return this.intGroups().concat( {
        Name: 'Create New',
        Id: 'CREATE_NEW_ID'
    } )
}, this);
然后在html中,不要引用
$root.intGroups
,只需使用
$root.dropdownpoptions

this.intGroups = ko.observableArray([]);
this.dropdownOptions = ko.pureComputed(function() {
    return this.intGroups().concat( {
        Name: 'Create New',
        Id: 'CREATE_NEW_ID'
    } )
}, this);