jorisroling / meteor-isotope

Do What The F*ck You Want To Public License
0 stars 2 forks source link

Implement Collection.observe and Tracker.afterFlush to run .isotope() when documents change. #3

Closed nadeemja closed 8 years ago

nadeemja commented 8 years ago

Hi,

If the content of the items change, then the item might cover other items if the new content is considerably larger.

I'm fixing this by manually calling .isotope() on changes to the cursor. Like this:

Template.studentQuestions.helpers( {
    studentQuestions: function () {

        questionsCursor = Questions.find( {
            schedule_id: FlowRouter.current().params.scheduleId,
            userType: 'student'

        }, {
            sort: {
                createdAt: -1
            }
        } );

        questionsCursor.observe( {
            changed: function ( id, fields ) {
                Tracker.afterFlush( function () {
                    $( 'ul.isotope' ).isotope();
                } );
            }
        } );

        return questionsCursor;
    }
} );

Perhaps it could be implemented out of the box?

jorisroling commented 8 years ago

I've put the changed observer in the code, as you suggested (v1.0.11).

Regards, Joris

On 01 Apr 2016, at 16:12, Nadeem Jabbar Qureshi notifications@github.com wrote:

Hi,

If the content of the items change, then the item might cover other items if the new content is considerably larger.

I'm fixing this by manually calling .isotope() on changes to the cursor. Like this:

Template.studentQuestions.helpers( { studentQuestions: function () {

    questionsCursor = Questions.find( {
        schedule_id: FlowRouter.current().params.scheduleId,
        userType: 'student'

    }, {
        sort: {
            createdAt: -1
        }
    } );

    questionsCursor.observe( {
        changed: function ( id, fields ) {
            Tracker.afterFlush( function () {
                $( 'ul.isotope' ).isotope();
            } );
        }
    } );

    return questionsCursor;
}

} ); Perhaps it could be implemented out of the box?

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/jorisroling/meteor-isotope/issues/3

nadeemja commented 8 years ago

My friend, you are certifiably awesome! <3