Error selecting Items (TypeError: Cannot convert undefined or null to object)
When I click on any items ( selected or not) i get:
TypeError: Cannot convert undefined or null to object at isteven-multi-select.js:443 at angular.js:16174 at e (angular.js:4889) at angular.js:5269
from chrome console, using angular 1.3.14
I get this erro coping the basic example ( Browser ), so same dom and model. Thank you
+1 Debugging the js file shows that the syncItems method is called twice.
Hi guys,
Can please help to replicate the issue in JsFiddler or Plunker? Thanks.
hi, I cant reproduce this error but for now, I fixed it by injecting below code into the syncItems method to prevent it being called twice.
if (e.originalEvent.prevent) return;
e.originalEvent.prevent = true;"
I guessed for some reason, 2 divs inside your checkBoxContainer are overlapped making the syncItems called twice.
@thucnc ,
Many thanks for the info, much appreciated. I will try to see what is actually happening. Meanwhile, I'll keep the issue open as a reference for people who have similar problem.
This fix works fine for me! thank you
+1.
Seeing the same issue in Chrome. Works in Firefox 37.
The fix recommended by thucnc fixes it.
@thucnc fix worked for me. One thing I have noticed is that this only occurs when testing on localhost, in live environment it works well without the fix
@isteven - is there an update with a fix for this issue? I get the same error as well. (v4.0.0). Cannot convert undefined or null to object, ErrorStack: TypeError: Cannot convert undefined or null to object at /scripts/angular-multi-select/isteven-multi-select.js:442:51 at /scripts/angular.js:16414:28 at completeOutstandingRequest (/scripts/angular.js:4940:10) at /scripts/angular.js:5328:7
On debugging, I find that clickedItem is null inside the $timeout function at:
clickedItem = angular.copy( item );
if ( clickedItem !== null ) {
$timeout( function() {
delete clickedItem[ $scope.indexProperty ];
delete clickedItem[ $scope.spacingProperty ];
$scope.onItemClick( { data: clickedItem } );
clickedItem = null;
}, 0 );
}
In my case, the user is rather fast and is able to click the item more than once before its selection state changes.
I'm also getting this same error (v4.0.0):
TypeError: Cannot convert undefined or null to object
at isteven-multi-select.js:443
at angular.js:16414
at completeOutstandingRequest (angular.js:4940)
at angular.js:5328
The fix recommended by @thucnc works, but I'd rather not modify the src as I use bower for dependencies.
Should this really be closed? The bug isn't actually fixed.
@JamesWooldridge ,
I'm not sure myself whether it should stay open or closed. I tried but I was unable to replicate this issue, and so far nobody helped me to replicate their problem in Plunker / JsFiddler.
If that fix works, I suggest you to fork & modify into your repo (or local dev folder).
@isteven, Thanks for such wonderful feature js.
I am still looking for this fix. i am using minified version from CDN js. I am not able to make any changes in JS.
If you think this is a fix then could you please update your JS and published new version of it. It would be very helpful for me and rest of the folks.
Note: I think to reproduce this is - select option very quick and randomly.
Looking forward to get this fix.