Quantcast
Channel: Ember.JS - Latest topics
Viewing all articles
Browse latest Browse all 4828

Check and uncheck the checkbox needs to reload the search item

$
0
0

@Boo wrote:

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.

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.

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 4828

Trending Articles