Javascript AngularJS:带multiselect的引导类型预选
我在我的angular应用程序中使用bootstrap multiselect。(引导程序2.3) 我想将相同的内容转换为引导typeahead,但用户仍然可以在搜索结果中选择多个值 我正在使用bootstrap typeahed的高亮功能向结果中添加复选框。 我指的是这个plnkr,但我仍然无法使我的代码工作 multiselect的旧代码:Javascript AngularJS:带multiselect的引导类型预选,javascript,angularjs,twitter-bootstrap,bootstrap-typeahead,bootstrap-multiselect,Javascript,Angularjs,Twitter Bootstrap,Bootstrap Typeahead,Bootstrap Multiselect,我在我的angular应用程序中使用bootstrap multiselect。(引导程序2.3) 我想将相同的内容转换为引导typeahead,但用户仍然可以在搜索结果中选择多个值 我正在使用bootstrap typeahed的高亮功能向结果中添加复选框。 我指的是这个plnkr,但我仍然无法使我的代码工作 multiselect的旧代码: 检查上次选择的值的步骤 $scope.selectOptions = function () { var index = fetching the
$scope.selectOptions = function () {
var index = fetching the index of checked values;
var selectedAttrFound = index>-1;
if (selectedAttrFound == true) {
angular.element("#attr-value-selector")
.multiselect('select', $scope.filterAttributes[index].attributeValues);
}
};
$scope.attrValuesWidget = angular.element("#attr-value-selector")
.multiselect({
numberDisplayed: 2,
enableFiltering: true,
maxHeight: "300",
onChange: function (element, checked) {
$scope.attributeActionValue = {
attribute: $scope.attributeSelected,
value: element.val(),
checked: checked
};
$scope.$apply();
}
})
.multiselect('dataprovider', $scope.configAttributeValuesList);
<select id='attr-value-selector' multiple='multiple' ></select>
尽管您可以轻松地在highlighter函数中添加复选框
highlighter: function( item ){
var bond = bondObjs[ item ];
return '<div class="bond">'
+'<input type="checkbox" class="mightBeRequiredToCollectTheSelectedResult">'
+'<img src="' + bond.photo + '" />'
+'<br/><strong>' + bond.name + '</strong>'
+'</div>';
}
荧光灯:功能(项目){
var bond=bondObjs[项目];
返回“”
+''
+''
+“
”+bond.name+“”
+'';
}
问题是,
- typehead.js在您单击其中一项后自动关闭其结果 搜索结果。你需要先覆盖它李>
- 然后,您还需要在文本字段中列出所选的值
- :纯AngularJS,能够休息选择
- :丰富的配置选项
- 或者旧的可靠的“精选”库(我不能发布更多链接)