簡體   English   中英

如何為流星中的動態按鈕編寫onclick功能

[英]How to write the onclick functionality for the dynamic button in meteor

 <template name="actionTemplate">

     {{#each action}}

        <button class="myButton" id={{_id}}>btn</button>

    {{> action}}
    {{/each}}
</template>


 <template name="action">
    <div class="sct" id={{_id}}>
    some text has to display
    </div>
    </template>

對於上面的行,我該如何編寫單擊功能以隱藏“ btn”按鈕。

如果您的模板名為say actionTemplate ,則應將事件函數編寫為

Template.actionTemplate.events({
"click .myButton" : function(event){
       var id= event.currentTarget.id;
       $('#'+id).hide();
});

這應該做的工作。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM