我试图从KendoComboBox获取所有列表项。
该列表是使用自定义angularjs指令构建的:
HTML
<input id="comboBox" />
sgComboBoxField指令:
'use strict';
angular.module('sgComponents').directive('sgComboBoxField', ['sgComboBoxService',
function(sgComboBoxService) {
return {
link: function (scope, element, attrs, ctrls) {
var dropdownlist = element.find('#comboBox');
dropdownlist.kendoComboBox({
//various options needed to set up the combox (like datasource) obtained from service
)};
// tried a breakpoint here in chrome but the items are not visible!
}
}
}]);
我的问题是,如果在DOM上加载了组合框,我如何从组合框中获取所有列表项?
答案 0 :(得分:0)
解决方案是使用$ timeout来给DOM加载时间,将dropdownlist对象转换为kendo对象(使用数据(&#39; kendoComboBox&#39;))然后调用它上面的jquery函数得到名单的孩子:
$timeout(function() {
var listItems = dropdownlist.data('kendoComboBox').ul.children();
listItems.each(function(index) {
console.log($(this));
});
});