0

Searchbox keep selected item

asked 2022-05-18 19:24:40 +0800

softteam gravatar image softteam
130 1 8

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:

image description

And then, we select North America again: image description

And I would like North America to keep selected in the searchbox.

Thank you, Javier

delete flag offensive retag edit

3 Answers

Sort by ยป oldest newest most voted
0

answered 2022-05-20 17:54:32 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

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);
        },
    });
});
link publish delete flag offensive edit
0

answered 2022-05-24 19:10:10 +0800

softteam gravatar image softteam
130 1 8

Hi,

I updated my example with this patch but it returns an error:

https://zkfiddle.org/sample/49hk31/14-searchbox-demo

link publish delete flag offensive edit
0

answered 2022-05-26 18:40:17 +0800

hawk gravatar image hawk
3250 1 5
http://hawkphoenix.blogsp... ZK Team

you should enclose the script with CDATA: https://zkfiddle.org/sample/49hk31/15-searchbox-demo

link publish delete flag offensive edit
Your answer
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2022-05-18 19:24:40 +0800

Seen: 12 times

Last updated: May 26 '22

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More