jimbo
jimbo

Reputation: 1018

Ember and external js scripts

Ok, i'm a really newbie to Ember JS, but i'm having a play and working my way through things. So far I'm really liking it, but…

I wanted to use something like: https://github.com/ed-lea/jquery-collagePlus, which created a masonry style layout.

I have create the route, and the navigation to that view, but… how do you apply the effect?

Normally a:

$(window).load(function () {
    $('.Collage').collagePlus();
});

would do the job at the bottom of the page, but i'm guessing popping in a:

App.GridRoute = Ember.Route.extend({
afterModel: function(){
$('.Collage').collagePlus();
}
});

Might be better, but that's not working…

any help, pointers on this welcome, be gentle as i'm not understanding it quite yet!

PS. i'm also using bootstrap and bootstrap ember (probably doesn't matter…)

Upvotes: 1

Views: 313

Answers (1)

edpaez
edpaez

Reputation: 1583

The place to do it it's the View, handling the didInsertElement event. I believe the View it's a good place to isolate any logic related to the DOM.

App.GridView = Ember.Route.extend({
    classNames: ['Collage'],

    didInsertElement: function(){
        this.$().collagePlus();
    }
});

A useful link:

Hope it helps!

Upvotes: 2

Related Questions