on-remove and on-select should fire AFTER addition/removal of the item.
I have a list of entities, each entity has a list of items, those items are the ones I'm displaying to the user in multiple mode.
When the user removes or adds and item to the list the on-action event fires, but it fires before the removal\addition of the item from the list, so I can not send my entity for update in the DB.
Side note: This will also compliment the way ui-grid works on edit. Example to what I mean:
html:
<ui-select multiple ng-model="exemption.selected.dutyTypes" theme="select2" on-remove="update" >
script (pseudo code):
$scope.update = function(){
$http.put("/exemptions/", exemption.selected); // cant do this because the item is not updated yet!!!
}
@gotenxds thanks for your explanation - to expedite the process you could consider posting a Plunkr test case that demonstrates the problem.
$timeout(function(){ctrl.onSelectCallback($scope, { $item: item, $model: ctrl.parserResult.modelMapper($scope, locals) }); });
I've moved the callback at the referenced commit for the onSelectCallback, however, the onRemoveCallback appears to already be in the correct place. Please post a demo of the feature breaking because without demonstration, it looks to me like an execution runtime issue that you would need to manage on your end.. Also, make sure to use the latest (v0.9.3 at the time of this comment)
Hi, here I made a plunker test: http://plnkr.co/edit/5czQ6iNn4dVMCcVf9ALr?p=preview
on-remove alerts the length on the list. As you can see this is as I described.
Thanks @gotenxds. Some more critical bugs have kept me busy and I'm busy at my day job right now. Feel free to open a PR that fixes this. The short explanation is that the callback is firing after the ctrl.selected has it's new value, but before the change is propagated to the external $scope model (in your example $scope.multipleDemo.selectedPeople) we have a race condition and the callback is called prior to updating the intended target selectedPeople.
+1
workaround is to use $timeout with 100 ms
I think this is fixed now, but it would be great if someone else could confirm.
Resolved by #501
how to get only ID and post in database