iron router - Meteor onRendered does not work with ironRouter -
my coffeescript
template.shiftdatatable.onrendered ( -> app.datatables() $('#shift-list-table').datatable pagelength: 10, "order":[[0, "asc"]] $('.datatables_filter input').attr('placeholder', 'search') )
my jade template
.table-responsive table#shift-list-table.table.table-vcenter.table-condensed.table-hover thead tr th shift code th shift type th shift start date tbody each shifts tr td {{code}} td {{type}} td {{formatdate createdat}}
the problem when go page using ironrouter (router.go, pathfor), onrendered run before has been rendered.
when happens me, use tracker.afterflush()
:
template.shiftdatatable.onrendered ( function () { tracker.afterflush ( function () { app.datatables() $('#shift-list-table').datatable pagelength: 10, "order":[[0, "asc"]] $('.datatables_filter input').attr('placeholder', 'search') }); });
schedules function called during next flush, or later in current flush if 1 in progress, after invalidated computations have been rerun. function run once , not on subsequent flushes unless afterflush called again.