# Check and uncheck the checkbox needs to reload the search item

**URL:** <https://discuss.emberjs.com/t/check-and-uncheck-the-checkbox-needs-to-reload-the-search-item/15264>\
**Category:** Questions\
**Created:** [August 10, 2018, 4:24am UTC](https://discuss.emberjs.com/t/check-and-uncheck-the-checkbox-needs-to-reload-the-search-item/15264 "2018-08-10T04:24:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Boo](https://avatars.discourse-cdn.com/v4/letter/b/7feea3/32.png) [@Boo](https://discuss.emberjs.com/u/Boo)\
**Post date:** [August 10, 2018, 4:24am UTC](https://discuss.emberjs.com/t/check-and-uncheck-the-checkbox-needs-to-reload-the-search-item/15264/1 "2018-08-10T04:24:51Z")

</div>

I’m having the search column with checkbox along with folder names. when I click the checkbox of corresponding folder, it will show their items. As well as when I click on multiple checkbox it will show their corresponding items. But when I uncheck the folder, the corresponding items doesn’t remove. So I need the hard reload or refresh when I check or uncheck the checkbox or need to clear the cache for every check or uncheck.

```auto
Checkbox: Core.component.Checkbox.extend({
    click: function () {
        var ret=null;
        var nav = this.get("controller").get('selectedNavigator');
        ret = this._super.apply(this, arguments);
        var states=null;
        Ember.run.schedule('sync', this, function () {
            Ember.run.schedule('render', this, function () {
                states = this.get('parentView.itemStates');
                var values = Object.keys(states).filter(function (key) {
                    if(states[key]){

                    return states[key];}
                    else{return;}
                });
                if (values.length === 0) {
                    Core.Action('core:contentHome', {});
                } else {
                    this.set('parentView.model.values',values);
                    nav.publish();
                }
            });
        });
        return ret;
    }
}),

```

In that code, **states[key]** defining the items get true if it checked and items get false if it unchecked and **nav.publish();** defining to show the items of checked.

```
publish: function () {
					var currentResultSet = this.get('resultSet'),
					    ctl = this.get('controller'),
						form = ctl.get('formModel'),
						resultSet,
						data = form.sleep(2000);
					if (Object.keys(data).length === 0) {
						Core.view.Menu.create({
							anchor: $('*[data-class-name="Core.Tab.Content.Controller.NavigationRefresh"]'),
							model: [
								Core.model.Menu.Item.create({
									label: "Please select something to search.",
									icon: 'dialog_warning'
								})
							]
						}).show();
						return;
					}
					resultSet = form.send();
					ctl.set('loadState', 'loading');
					ctl.set('resultSet', Core.model.BlankResultSet.create({
						loadState: 'loading',
						tabContext: Ember.get(form, 'resultSet.tabContext')
					}));
					resultSet.fail(function (err) {
						ctl.set('loadState', 'loaded');
						console.log(currentResultSet);
						ctl.set('resultSet', currentResultSet);
					}).always(function () {
						ctl.set('loadState', 'loaded');
					});
				},

```

Please provide suggestion on this.

---

<div class="post-metadata">

**Author:** ![ef4](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.emberjs.com/ef4/32/13470_2.png) [@ef4](https://discuss.emberjs.com/u/ef4)\
**Post date:** [August 11, 2018, 3:18am UTC](https://discuss.emberjs.com/t/check-and-uncheck-the-checkbox-needs-to-reload-the-search-item/15264/2 "2018-08-11T03:18:51Z")

</div>

Everything I said [here](https://discuss.emberjs.com/t/problem-of-search-the-folder-items/15219/2) applies equally well to this post.

Did you try to use any of my suggestions from that reply? You’re going to keep having painful bugs with the kind of code you’re showing here. You need to refactor little by little into cleaner patterns. There is no good reason to extend `Checkbox` to do what you’re doing.
