peerlibrary / meteor-blaze-components

Reusable components for Blaze
http://components.meteorapp.com/
BSD 3-Clause "New" or "Revised" License
354 stars 26 forks source link

How to use isRendered()? #112

Closed thearabbit closed 8 years ago

thearabbit commented 8 years ago

I would like to check the template is rendered (view ready), and then init any jquery

class Home extends BlazeComponent {
    onRendered() {
        if (isRendered()) {
            console.log('component is rendered');
            var $exDate = $('[name="exDate"]');

            $exDate.datetimepicker({
                format: 'DD-MM-YYYY'
            });
        } else {
            console.log('component is't yet render');
        }

    }
}

Home.register('Home');

Please help me.

mitar commented 8 years ago

You have to do if (this.isRendered()) {.

mitar commented 8 years ago

But inside onRendered, the component will be always rendered. Use isRendered inside autoruns and other reactive contexts where you care if the component is rendered.

thearabbit commented 8 years ago

Thanks a lot.