Let's say I want to do some jQuerry Stuff
// Do jQuery Stuff
$(document).ready(function(){
$("button").click(function(){
$("p").hide();
});
});
And I want to include this code in either the route or the controller, I'm quite sure I cannot implement this because there's no hook function (I.E. model(), renderTemplate(), etc.
that I can use that guarantees that all the elements in the DOM have safely been rendered.
Now, if I were doing this in a component, I know I could call the didInsertElement
hook and that could would allow me to run the code above.
My Use Case
I want to use a library called ScrollMagic which would require jQuery to configure. Someone other than me has already written a lot of code in the route and controller. We could easily just move this to a component (and we probably will), but I still wanted to ask this for my own curiousity.
Question
Is there any hook in either the route or the model that guarantees all the elements of that template have been rendered in the DOM? If not, why is that? After all, you have that hook available in a component.
Aucun commentaire:
Enregistrer un commentaire