selectivity
selectivity copied to clipboard
Selectivity removes option on select.
The Selectivity removes the option(DOM), when they are selected. Is it a default behavior of this library
Yes, for multiple selection inputs this is the deafult behavior. What do you want instead?
is there any way to stop this removal of the dom Action.
Currently there's no option for that, but if you're curious it's the filterResults()
method that's responsible for this: https://github.com/arendjr/selectivity/blob/master/src/selectivity-multiple.js#L119
Possible solutions could be making this entire method configurable (I guess that would be my preference), introducing an option for this specific behavior, or creating your own InputType that's otherwise the same as the Multiple InputType, but differs in this behavior (might be preferable if you have other requirements as well where you want diverge from the default behavior).
I don't know for what reason Amerr want to keep the options in DOM, but I have a comment on the same subject... Please forgive me if this should have been posted as a new issue instead.
I found it annoying/buggy that a removed item dont re-appear in the option list until the dropdown is re-opened.
To re-produce using multi-select dropdown with closeOnSelect = false:
- Click the input to open the dropdown.
- Select one item.
- Remove the just added item without closing the dropdown first. = The item is removed but won't re-appear in the dropdown option list!
However, if the dropdown is closed and re-opened in between the selecting and removal of the item, it will re-appear in the dropdown list.
My solution (jQuery):
Row 1267:
//Changed results to filteredResults to avoid duplicates
//this.results = (options.add ? this.results.concat(results) : results);
this.results = (options.add ? this.results.concat(filteredResults) : filteredResults);
Row 2007:
if (this.dropdown) {
//Add itemback to dropdown results
if(event.removed)
{
this.dropdown.results.push(event.removed);
}
this.dropdown.showResults(this.filterResults(this.dropdown.results), {
hasMore: this.dropdown.hasMore
});
}