beforeRemove callback called for each row inside datatable
gentunian opened this issue · 2 comments
gentunian commented
I'm using tabular and a template for a column that displays actions buttons:
Tabular is initialized with the last column as a template:
{
tmpl: Meteor.isClient && Template.actionCell,
sWidth: "20px",
sClass: "td-center",
}
Template is something like this:
<template name="actionCell">
<div class="btn-group" role="group">
<button id="{{this._id}}" type="button" class="btn btn-xs btn-primary" data-toggle="modal" data-target="#editEntryDialog"><i class="fa fa-edit"></i>
</button>
{{# quickRemoveButton collection="MyCollection" _id=this._id onError=onError onSuccess=onSuccess beforeRemove=beforeRemove class="btn btn-xs btn-danger"}}
<i class="fa fa-trash"></i>
{{/quickRemoveButton}}
</div>
</template>
I wrote a simple helper to test the functionality:
Template.actionCell.helpers({
beforeRemove: function() {
alert('a dialog');
}
});
When the datatable loads, the alert dialog gets invoked. I think this is due the case that the content block is rendered and so the helper is being called.
Is it possible to use the template as a content block and make use of callbacks?
Note: I'm sorry for the editions, I had a lot of troubles with my touchpad.
aldeed commented
Since beforeRemove
expects a function, your helper function needs to return a function. It can be confusing, but it makes sense if you think about it hard enough. :)
Template.actionCell.helpers({
beforeRemove: function() {
return function () { alert('a dialog'); }
}
});