Reputation: 15519
Using jQuery and Meteor I am trying to bind the TokenInput plugin to the DOM like so:
$(function(){
console.log("binding tokeninput");
$(".nameInput").tokenInput(friendsList.data)
});
The issue is that the particular DOM element is being redrawn (removed from the DOM and then re-added in a quick flash) occasionally. I need to ensure that the plugin is ALWAYS in effect on that input.
A few things come to mind:
Upvotes: 0
Views: 531
Reputation: 75945
If you're DOM element being removed by something reactive. If mytiem
changes its going to fire the 'rendered' template callback
e.g
<template name="MeteorIsAwesome">
{{#each myitem}}
<div class="dom element meteor">
</div>
{{/each}}
{{!comment - you can put it here or above}}
<input class="nameInput" type="text">
</template>
Js (kind of the callback you might be looking for)
Template.MeteorIsAwesome.rendered = function () {
$(".nameInput").tokenInput(friendsList.data)
}
One thing only worries me is if it ignores the state of the tokenbox when redrawing so it might become double tokenized
Upvotes: 1