wenzhixin / multiple-select

A jQuery plugin to select multiple elements with checkboxes :)
http://multiple-select.wenzhixin.net.cn
MIT License
1.9k stars 652 forks source link

getSelects() undefined is not iterable #615

Closed p-wieser closed 7 months ago

p-wieser commented 7 months ago

Summary When calling 'getSelects' / 'setSelects' methods, get an error message:

Uncaught TypeError: undefined is not iterable (cannot read property Symbol(Symbol.iterator)
    at a (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:35668:2387)
    at n.value (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:35668:59163)
    at HTMLDivElement.<anonymous> (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:35668:63777)
    at Function.each (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:36094:19)
    at jQuery.fn.init.each (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:35916:17)
    at $.fn.multipleSelect (modules.js?hash=59ced33a08568008ca6aa6151312e8c1a0bcaa3a:35668:63515)

Context I am using last 1.7.0 version of multiple-select, inside a Meteor 2.13.3 application using Blaze templating. HTML Code

 <select class="multiple-select js-authent w-100" multiple="multiple" title="{{ i18n key="organizations.panel.authent_title" }}">
     {{#each it in authentList }}
         <option value="{{ authentValue it }}" {{ authentSelected it }} {{ authentDisabled it }}>{{ authentLabel it }}</option>
     {{/each}}
 </select>

JS

 self.$( '.js-authent' ).multipleSelect({
     selectAll: false,
     classes: 'form-control',
     onClick( data ){
         console.debug( self.$( '.js-authent' ).multipleSelect( 'getSelects' ));
     }
 });

This is probably a misuse of mine, but I do not see where I am wrong ? Could someone help, please ?

wenzhixin commented 7 months ago

You can use id (#js-authent example) instead: https://multiple-select-live.wenzhixin.net.cn/code/wenzhixin/16531, or save the select to a variable: https://multiple-select-live.wenzhixin.net.cn/code/wenzhixin/16530

p-wieser commented 7 months ago

That works ! Thanks a lot for your work, and your help. Best regards Pierre