2016-05-27 138 views
0

我有以下代码,它动态获取数据并将其推入相扑选择。jquery.sumoselect不显示复选框

<select id="geoSel_location_2"> 



</select> 


<script type="text/javascript"> 

    jQuery(document).ready(function() { 

     var returnSelect = jQuery('#geoSel_location_2'); 

     returnSelect.SumoSelect({placeholder: 'All Suburbs'}); 

     jQuery.getJSON("/cfcs/system.cfc?method=getSelectsRelated&returnformat=json&queryformat=column",{"type":"location","id":4,"index":2},function(res,code) { 
      if(res.ROWCOUNT > 0){ 
       for(i=0; i<res.ROWCOUNT; i++){ 
        var val = res.DATA.OPTION_VALUE[i]; 
        var text = res.DATA.OPTION_TEXT[i]; 
        returnSelect[0].sumo.add(val,text); 
       }; 
      }; 
     }); 

    }) 

</script> 

选项负载精美,但多选复选框不每个选项旁边示出。我认为他们默认显示。

jsfiddle是上述的简化版本。

JSFIDDLE

+0

你能在'Jsfiddle'复制呢? –

回答

1

OK,咄,解决的办法是增加 “多个=” 多”,即

<select "multiple="multiple" id="geoSel_location_2"> 
    <option value="1">Auckland</option> 
    <option value="2">Wellington</option> 
    <option value="3">Christchurch</option> 
    <option value="4">Dunedin</option> 
</select>