blikblum / tinybind

Lightweight and powerful data binding + templating solution
http://blikblum.github.io/tinybind/
MIT License
80 stars 14 forks source link

Uncaught TypeError: el.options.forEach is not a function #16

Closed ProjectOrangeBox closed 5 years ago

ProjectOrangeBox commented 5 years ago

I added a select+multiple to my html form and bound it. but when you select the options in the list (in the browser) I get a "Uncaught TypeError: el.options.forEach is not a function error." it's around line 396-ish in the dist/* file.

<select name="mselect" multiple="multiple" class="form-control">
<!-- tinybind: each-row -->
<option value="1">jam</option>
<option value="2">cookie</option>
<option value="3">cat</option>
<option value="4">dog</option>
<option value="5">cake</option>
<option value="6">orange</option>
<option value="11">place holder</option>
</select>
    } else if (el.type === 'select-multiple') {
      el.options.forEach(function (option) {
ProjectOrangeBox commented 5 years ago

Fixed it with a "old fashion" loop around line 395 in the dist/*.js file

for (var i = 0; i < el.options.length; i++) {
    if (el.options.item(i).selected) {
        results.push(el.options.item(i).value);
    }
}
blikblum commented 5 years ago

Fixed in master