meteoric / meteor-ionic

Ionic components for Meteor. No Angular!
http://meteoric.github.io
MIT License
1.51k stars 219 forks source link

Page reloads when subscription is changes #383

Open Ist14labs opened 7 years ago

Ist14labs commented 7 years ago

I want to implement infinite scroll pagination by Iron.Router state variables.

That is my subscription code:

Router.route('/categories/', {
    loadingTemplate: 'loading',
    waitOn: function () {
        var limit=parseInt(this.state.get('limit'))||10;
        return Meteor.subscribe('categories', {}, {limit:limit});
    },
    action: function () {
        if(!this.state.get('limit')){
            this.state.set('limit',10);
        }
        this.render('categories', {
            data: {
               categories:Categories.find()
            }
        });
    }
});

My publication code:

Meteor.publish('categories', function (query, params) {
    return Categories.find(query, params)
});

And my template:

<template name="categories">
    {{#contentFor "headerTitle"}}
        <h1 class="title">Sections</h1>
    {{/contentFor}}
    {{#ionView}}
        {{#ionContent}}
            {{#ionList class="my-class"}}
                {{#each categories}}
                    {{#ionItem href=getHref avatar=true}}
                        <img src="{{image}}">
                        <h2>{{title}}</h2>
                    {{/ionItem}}
                {{/each}}
            {{/ionList}}
        {{/ionContent}}
    {{/ionView}}
</template>

So, when I'm call Router.state.set('limit', 20) I expect that items just be added at the end of list, but I get full page reload, including animation of page and reset of scroll position. Is there a way to turn off that behavior when changing router state?