meteor / meteor/blaze

Bootstrap select picker is not correctly removed / disposed during Template descruction

Open
#380 6 comments 0 reactions 0 assignees View on GitHub
hacktoberfest
Dominant language
JavaScript
Stars
543
Forks
117
Avg merge
6h 18m
Merged PRs (30d)
2

Description

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

```html


{{#each options}}
{{label}}
{{/each}}

```

In our onRendered we do `$(this.jquerySelector).selectpicker();` to initialise the control. So in the DOM instead of just our select I now have.

```html

//new parent added by the control
//our initial select
//added by the control

```
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 `
` 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?

Contributor guide

Open the contributing guide

Research direction

Start with the multipleSelectFilter template and trace its onRendered selectpicker initialization and onDestroyed destroy call during repeated view switching. Reproduce the toggle described in the issue and inspect template teardown. Done means the generated enclosing div and button are removed along with the original select.

Written by the indexing model from the issue text.

Assessment

Tech stack
bootstrap, javascript, jquery
Domain
frontend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.