2014-07-03 50 views
0

我试图从KendoComboBox获取所有列表项目。如何从KendoComboBox获取所有列表项目

名单已使用定制angularjs指令建:

  1. HTML

    <input id="comboBox" /> 
    
  2. 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

解决方案是使用$超时给DOM时间加载,将下拉列表对象转换为kendo对象(使用data('kendoComboBox')),然后调用jquery函数来获取列表的子元素:

$timeout(function() {      
    var listItems = dropdownlist.data('kendoComboBox').ul.children(); 
    listItems.each(function(index) { 
     console.log($(this)); 
    });     
}); 
相关问题