EvanOxfeld / angular-selectize.js

Angular Selectize directive for a hybrid textbox + <select> box. Supports ngOptions and two-way bindings.
MIT License
34 stars 16 forks source link

Clearing the selectize control results in TypeError: selectize.options[i] is undefined #15

Closed smap closed 10 years ago

smap commented 10 years ago

Example: http://plnkr.co/edit/0LITR4hATIlt8Hz0dcq7

selectize.options[i] is undefined

You can do:

210          if (!attrs.ngOptions) {
211            return model.map(function(i) {
212                if (i != '') {
213                    return selectize.options[i].value
214                }
215                return '';
216            });
217          }
Chris-Gillis commented 10 years ago

I can't reproduce this with your plunkr. I tried with Chrome 36 and Safari 7 on OSX.

Can you give any more details on how to reproduce it?

smap commented 10 years ago

Windows 7 Chrome 36.0.1985.125 m

TypeError: Cannot read property 'value' of undefined
    at http://run.plnkr.co/BvoPpxCLPDHrHO10/angular-selectize-1.3.0.js:211:71
    at Array.map (native)
    at getSelectedItems (http://run.plnkr.co/BvoPpxCLPDHrHO10/angular-selectize-1.3.0.js:211:26)
    at http://run.plnkr.co/BvoPpxCLPDHrHO10/angular-selectize-1.3.0.js:121:35
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:111:59
    at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:33:82)
    at http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:36:251 

Windows 7 Firefox 31.0 + Firebug 2.0.2

Error: selectize.options[i] is undefined getSelectedItems/<@http://run.plnkr.co/RqPhg9Rn1jgDpanL
/angular-selectize-1.3.0.js:211:44 getSelectedItems@http://run.plnkr.co/RqPhg9Rn1jgDpanL
/angular-selectize-1.3.0.js:211:13 scheduleUpdate/updateTimer<@http://run.plnkr.co
/RqPhg9Rn1jgDpanL/angular-selectize-1.3.0.js:121:19 e/h<@http://ajax.googleapis.com/ajax/libs
/angularjs/1.2.5/angular.min.js:111:49 e@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5
/angular.min.js:33:80 dd/h.defer/c<@http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5
/angular.min.js:36:251

Windows 7 Internet Explorer 11.0.9600.17207

TypeError: Не удалось получить свойство "value" ссылки, значение которой не определено или является NULL
   at Anonymous function (http://run.plnkr.co/tHGuHSuFYf4VYA4y/angular-selectize-1.3.0.js:211:44)
   at getSelectedItems (http://run.plnkr.co/tHGuHSuFYf4VYA4y/angular-selectize-1.3.0.js:211:13)
   at Anonymous function (http://run.plnkr.co/tHGuHSuFYf4VYA4y/angular-selectize-1.3.0.js:121:15)
   at Anonymous function (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:111:49)
   at e (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:33:80)
   at Anonymous function (http://ajax.googleapis.com/ajax/libs/angularjs/1.2.5/angular.min.js:36:251)
EvanOxfeld commented 10 years ago

@smap Thanks for submitting the issue!

@z3roshot Clearing the selectize control results in a call to getSelectedItems with an empty string, causing the TypeError. I updated the issue title.

EvanOxfeld commented 10 years ago

@smap We released 1.3.1 to Bower with the fix for this issue.