Skip to content
This repository has been archived by the owner on Dec 16, 2019. It is now read-only.

onItemDeselect does not return object #46

Closed
simeg opened this issue Dec 10, 2014 · 4 comments
Closed

onItemDeselect does not return object #46

simeg opened this issue Dec 10, 2014 · 4 comments

Comments

@simeg
Copy link

simeg commented Dec 10, 2014

My options:
$scope.optionsMultiSelect = {
displayProp: 'value', idProp:'value', externalIdProp: '' };
externalIdProp is set to '' so it should return an object.

onItemSelect returns the object. onItemDeselect just returns value which is a string.

Have I misunderstood the documentation or is this a bug?

@DavidCasillasRivero
Copy link

When setting externalIdProp='' the event onItemDeselect is returning an object with just the id property, while the event onItemSelectreturns the whole item. Inspecting the code you can see the difference:

                if (!dontRemove && exists) {
                    $scope.selectedModel.splice(_.findIndex($scope.selectedModel, findObj), 1);
                    $scope.externalEvents.onItemDeselect(findObj);
                } else if (!exists && ($scope.settings.selectionLimit === 0 || $scope.selectedModel.length < $scope.settings.selectionLimit)) {
                    $scope.selectedModel.push(finalObj);
                    $scope.externalEvents.onItemSelect(finalObj);
                }

Here finalObj has an item with all properties (id, and labelplus any other) while findObj just has the id property. The event onItemSelectis being called with finalObjwhile onItemDeselect is called with findObj.

I have modified myself the line of code for testing and everything is going ok.

Is this a bug? Will it be fixed?

@dgwaldo
Copy link

dgwaldo commented Aug 13, 2015

Having the same issue here... This is a bit of a tough bug, because I have multiple drop-downs, and I can't figure out what my id's relate to as far as objects go...

@pkempenaers
Copy link
Collaborator

Setting externalIdProp to "" will return full items instead of only id.

@pybelecalo
Copy link

Hello pkempenaers,

This bug is not fixed. Like he says DavidCasillasRivero, we are mandated to change findObj to finalObj to resolve our problem.

This bug must to be fixed.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants