-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi,
I would like to know how can we make a searchbox to keep selected item when user selects an already selected item.
For instance, in this fiddle: https://zkfiddle.org/sample/49hk31/9-searchbox-demo
If we select North America:
And then, we select North America again:
And I would like North America to keep selected in the searchbox.
Thank you, Javier
Usually, selecting one item repeatedly in single-selection mode doesn't change the selection. Please apply the patch to fix the issue:
zk.afterLoad('zkmax.inp', function() {
var exWidget = {};
zk.override(zkmax.inp.Searchbox.prototype, exWidget, {
_doSelectItem: function(item, bulk) {
var $item = jq(item),
selectedClass = this.$s('selected'),
selected = $item.hasClass(selectedClass);
if (!this._multiple && selected){
return; //select the current selected item, keep selected, do nothing
}
exWidget._doSelectItem.apply(this, arguments);
},
});
});
Hi,
I updated my example with this patch but it returns an error:
you should enclose the script with CDATA: https://zkfiddle.org/sample/49hk31/15-searchbox-demo
Asked: 2022-05-18 19:24:40 +0800
Seen: 12 times
Last updated: May 26 '22