Can't access jquery in template rendered?

Can’t access jquery in template rendered

Template.productDetail.onRendered(function () {
   $('.selector').inputmask(.............);
});

And then I tried open the browser console and do agian, It is work fine.
Please help me.

template HTML code would be useful…

excuse me, could you explain?

It is hard to comment when we see just 1 line in onRendered pointing to some selector class
but not HTML part of template where that class should be used.
Is it directly in that template, or in some child template ? etc…
paste more code, best would be whole HTML of productDetail template

I have any problem for init jquery package such as inputmask, dateTimePicker... within template rendered

// html
<template ...>
        {{#autoForm collection=Exchange id="cpanel_exchangeUpdate" data=this type="update"}}
           {{> afQuickField name="exDate" type="text"}}
           {{> afQuickField name="exAmount" type="text"}}
        {{/autoForm}}
</template>

And the I would like to init the text box with

// Js
Template.myTpl.onRendered(function () {
   $('[name="exDate"]').datetimepicker(.............);
   $('[name="exAmount"]').inputmask(.............);
});

Don’t work, and then I tried open the browser console and do again it work fine.

Cause autoform is separate template on it’s own and quickFields have their own templates.

I would suggest to create your own templates for these afQuickField’s and init them inside these templates.
I used custom template in my blog, but without customizing it’s own onRendered.
Maybe it will inspire you how to do it yourself.

And I would look for autoform plugins, for example https://atmospherejs.com/aldeed/autoform-bs-datetimepicker

Thanks for your helping, some init plugins don’t work (mostly on update form).
I don’t understand how to init it after view is ready.

well, onRendered means that static html of given template is ready.
but all other child templates or #each #with #if blocks etc does not have to be yet

Could you example me through your advice: .......I would suggest to create your own templates for these afQuickField's and init them inside these templates.................

in pasted blog I used custom template, if you add your own JS file for it where you initialize it as datepicker, it would become datepicker.

but, there is already autoform plugin for that.

In this case I would like to use inputmask with autoform

I have nothing else to add.
Good luck.