-
-
Notifications
You must be signed in to change notification settings - Fork 115
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bootstrap select picker is not correctly removed / disposed during Template descruction #380
Comments
We had the same issue. We have noticed that blaze does not destroy first level added element. As a workaround, we have embedded the <template name="selectPicker">
<div>
<select id="{{htmlId}}" name="{{name}}" class="border-1 border-light rounded-2 form-control" {{otherAttributes}}>
{{#each options}}
<option value="{{value}}" class="{{../optionClass}}" selected="{{selected ../value value}}" data-icon="{{colorClass}}">{{title}}</option>
{{/each}}
</select>
</div>
</template> We always add a wrapping tag that must not be modified by any external library. <template name="Icon">
<span>
<i class="{{class}}" style="{{style}}" {{otherAttributes}}></i>
</span>
</template> |
@ziedmahdi thank you for clarifying, I actually thought all the time the |
This bug is reproducible in the following way: use jquery or vanilla DOM manipulation and replace the root component of the template with any custom code but don't use any Blaze functionality, such as reactive vars, tracker or Blaze API. For example: <template name="test"><div class="test-root">hello</div></template> Add this to any parent template with a conditional, such as : {{#if condition}}{{> test}}{{/if}} Now manipulate the template's DOM via jquery in an event that is triggered in the parent template: const target = $('.test-root')
const parent = target.parent()
// at this point starts the problem, where
// the DOMRange can't catch up anymore:
target.remove()
parent.append('fooooo') The template will now display |
Related to #353 |
we had the smiliar issue with select2, jquery select2 append its html part in else of DOM
when edditing is
we had this before working, but recently updating the meteor cause us this issue. |
Can you restore the Meteor and Blaze versions where this was working? |
original finding by @lynchem
So I tried to dig into the issue we were having a little more. I believe the problem stems from a jquery control modifying the DOM. Our template is one we use for filters in a number of places. The reason we noticed the issue here is because on this particular page you can toggle from two sets of pre-defined values so it destroys and recreates the template. The template looks like this
In our onRendered we do
$(this.jquerySelector).selectpicker();
to initialise the control. So in the DOM instead of just our select I now have.In our onDestroyed we call
$(this.jquerySelector).selectpicker("destroy");
but it doesn't clean up any of the new elements it created and leaves the button & enclosing div. I removed the onDestroyed callback entirely incase it was somehow preventing the default destruction from happening and it also only destroys the initial select that was part of our template. So every time I switch views on this page I end up with the old<div><button></button></div>
lying around.Has something changed with how we track what we need to remove? I'm not sure if the previous behaviour was simply to nuke everything and now we're trying to track what we should delete?
The text was updated successfully, but these errors were encountered: