문제

What is the use of Template.myTemplate.rendered in Meteor?. I had studied the document but i didn't understand the exact functionality.The document says Provide a callback when an instance of a template is rendered. What is the meaning of instance of a template is rendered.Can you please suggest me with an example?

도움이 되었습니까?

해결책

When the callback is fired, an instance of the template has been rendered (added to the document). It can be useful if you for example want to manipulate the elements in the template through the use of a JavaScript library, for example CodeMirror, as I used in one of my projects. For example:

<template name="test">
    <textarea></textarea>
</template>
Template.test.rendered = function(){
    // Make the textarea highlight the code (kind of).
    var myCodeMirror = CodeMirror.fromTextArea(this.find('textarea'))
}
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top