Equivalent to document ready

(Arran Scott) #1


What is the best way to achieve an equivalent to document ready in jquery?

I’ve tried a few things but to no avail.


(Dean Taylor) #2

Check out this post here:

(Joe Buhlig) #3

@DeanMarkTaylor has a good link there. Here’s what I’ve used in the past:

$(document).on('page:change', function(event) {
    your code here

(Arran Scott) #4

Great, cheers guys.

Where would I add the following code if i’m writing a plugin? In the view or in the template?


(Arran Scott) #5

Also, @joebuhlig - I can’t seem to get that code working.

I’ve tried putting it in every single place I imagine it should work and it’s not working.

Apologies for my questions, I’m still trying to navigate my way around.


(Rafael dos Santos Silva) #6

Did you go trough @eviltrout tutorials on plug-ins at the #howto section?

Also, my ember-fu isn’t strong, but you won’t put code like this in neither view nor template. This belongs to a controller or model depending on what you’re doing.

(Arran Scott) #7

Yeah, I’ve been through the plugin tutorials - I’ve got the plugin working but I’m just failing miserably trying to execute some jquery once the page has loaded. I’ve been on it for hours now, maybe I just need to familiarise myself with Ember before I even attempt to create a plugin.

By the way it’s the slick carousel I’m trying to initialise so if you or anyone knows how to do this I would be eternally grateful.

(Joe Buhlig) #8

I’m not sure what the best practice is here, but I’ve put it in a script tag within handlebars connectors in the past.