Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reactive Query Question #34

Open
fxv opened this issue May 29, 2014 · 4 comments
Open

Reactive Query Question #34

fxv opened this issue May 29, 2014 · 4 comments
Labels

Comments

@fxv
Copy link

fxv commented May 29, 2014

Thank you for making this package. It seems I cannot get the reactive query to work properly. First, I include my datatable component:

{{> DataTable groups }}

Then I setup the data in my controller:

Template.manageGroups.groups = function() {
    return {
        columns: [
                     ...
            ],
        subscription: "all_groups",
    query: Session.get('reactiveQuery')
    }
}

I publish data server side:

var GroupsTable;
    GroupsTable = new DataTableComponent({
        subscription: "all_groups",
        collection: Groups,
        query: function(component) {
            component.log("userId: " + this.userId);
            return { userId: this.userId }
        },
        debug: "userId"
    });
    GroupsTable.publish();

I tried to followed the sample code for reactive query

Template.manageGroups.helpers({
   reactiveQuery: function() {
       return Session.get('reactiveQuery');
   }
});

Template.manageGroups.events({
    'change #filter-groups': function (e, t) {
        var query = Session.get('reactiveQuery'),
        value, active, filter;

        filter = $('#filter-groups').val();

        if (filter === "all") {
            delete  query.isActive;
        } else {
            if (filter === "active")
                value = true;
            if (filter === "inactive")
                value = false;

            active = {
                isActive: value
            }
            _.extend(query, active);
        }
        Session.set('reactiveQuery', query);
    }
});

When the page loads, I can filter the table by selecting one of the options. If I select another option, however, the table doesn't redraw, so I can only filter once. I also tried to get it to work by creating a datatable that already exists in the DOM with no success. Do you have any suggestions on how I can get this to work? Thank you for your time.

@gjolund
Copy link
Contributor

gjolund commented May 30, 2014

Are you receiving any errors in the console?

@gjolund gjolund added the bug label May 30, 2014
@fxv
Copy link
Author

fxv commented May 30, 2014

I get no errors in the console unfortunately.

@gjolund
Copy link
Contributor

gjolund commented May 30, 2014

I've been able to replicate the issue, investigating now.

@serenitus
Copy link

+1 this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants