meteor-tabular
meteor-tabular copied to clipboard
Update main.js
Allow a reinitializing. For example, if we change an app language. Below you can see a simple way to make i18n for a tabular table. Just change Session.set("currentLanguage", "lang"), where lang is a language of the user and the tabular table will be reinitialized automatically.
<template name="yourtemplatewithtabular">
{{> tabular table=TabularTables.yourTable id="tabularYourTable" class="ui striped table"}}
</template>
Template.yourtemplatewithtabular.onCreated(function() {
Tracker.autorun(function() {
$.extend(true, $.fn.dataTable.defaults, {
language: {
"decimal": "",
"emptyTable": TAPi18n.__("No data available in table"),
"info": TAPi18n.__("Showing _START_ to _END_ of _TOTAL_ entries"),
"infoEmpty": TAPi18n.__("Showing 0 to 0 of 0 entries"),
"infoFiltered": TAPi18n.__("(filtered from _MAX_ total entries)"),
"infoPostFix": "",
"thousands": ",",
"lengthMenu": TAPi18n.__("Show _MENU_ entries"),
"loadingRecords": TAPi18n.__("Loading"),
"processing": TAPi18n.__("Processing"),
"search": TAPi18n.__("Search"),
"zeroRecords": TAPi18n.__("No matching records found"),
"paginate": {
"first": TAPi18n.__("First"),
"last": TAPi18n.__("Last"),
"next": TAPi18n.__("Next"),
"previous": TAPi18n.__("Previous")
},
"aria": {
"sortAscending": TAPi18n.__("activate to sort column ascending"),
"sortDescending": TAPi18n.__("activate to sort column descending")
}
}
});
Session.set('Tabular.reinit', Session.get("currentLanguage"));
});
dataTablesSemanticUI(window, $);
});
related with #94, #85
I think this PR should not be approved as it's very specific to an app feature. the package is only using session in https://github.com/Meteor-Community-Packages/meteor-tabular/blob/e9d15a7b758b67bb3930080c4442db9b927393cf/client/main.js and we should convert it to reactiveVar. what do you think?
I think, since the PR is 6 years old we should edit it until it fits the modern requirements. From that point I'm with you @guncebektas to use reactive var and make it independent from specific use cases.
it will be hard to merge https://github.com/Meteor-Community-Packages/meteor-tabular/pull/448 but after it is completed I can work to remove the session. It might be good starting point for me.
If you have any concerns regarding #448 please comment there so we can make this the best possible solution