Do they do the same thing ?
Which one should I use inside client?
if ( Meteor.is_client ) {
Meteor.startup(function () {
// my code here
});
}
or
if ( Meteor.is_client ) {
$(function() {
// my code here
});
}
As far as I can tell, Meteor.startup
(on the client) is very similar to jQuery's $
function. The main advantage of using it is that it's the same API on client and server, so if you want to write startup code in files that are run on both client and server, Meteor.startup
will just work. (Also, I personally find Meteor.startup
to be easier to read and more self-documenting than $
.)
I just ran into an issue that $
was called before template rendering so I hade to use Meteor.startup
So I'd say that if you need to work with DOM elements you have to use Meteor.startup
(I used it for the jQuery File Upload plugin)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With