[SOLVED] Templates with tmpl in aldeed:tabular not being destroyed

Calling all aldeed:tabular users. This package is not being updated much lately but for the most part does an excellent job. We’ve used them extensively in both our apps. We’ve now tracked down one bug that’s really annoying us. Here’s the link .

Basically it leaves user specified templates (using tmpl) lying around if the cells are removed dynamically. The simplest case is a delete button on a row for example. That template that contains the delete button code and event handler will still be active after the row is removed and will not be destroyed when you destroy the tabular. If you have any helpers in the template they will be re-running when the collections they are depending on change. We had lots of mysterious exceptions firing and finally tracked it down to this.

We had a quick look to see if there was any obvious mistake but doesn’t seem that way. Has anyone else ran into this ?

1 Like

We cloned and updated tabular to keep track of all the blaze views it creates and properly destroy them. If you use this package and the tmpl property you really should have a look at this. Will submit a PR soon.

We confirmed that onDestroyed is not called.
We will wait for your PR.

1 Like

@ixdi - Here’s the PR

Or you can use our fork if you can’t wait - it’s in the devel branch.

Ok now, thanks!
Although the destroy of each template is called now when a row is removed. We imagine that it is a normal behavior since the table is recreated.

Exactly. Every time there’s a change in the autorun containing the fetch.

Changes listed from aldeed’s comments:
// * DataTables reran ajax due to sort changing. // * DataTables reran ajax due to page changing. // * DataTables reran ajax due to results-per-page changing. // * DataTables reran ajax due to search terms changing. // *selectorattribute changed reactively // * Docs were added/changed/removed by this user or // another user, causing visible result set to change.

So each time that happens DT will call back to Tabular to create new blaze views for each row. So we delete the old ones before it. There might be some way to be a bit cleverer here and reuse them but I don’t think it’s trivial.