omines / datatables-bundle

DataTables bundle for Symfony
https://omines.github.io/datatables-bundle/
MIT License
255 stars 114 forks source link

JS events (draw|init) does not fire when language translations are included #136

Closed jkabat closed 4 years ago

jkabat commented 4 years ago

Translations provided in options create conflict with JS datatables events. I'm not sure if the issue is caused by contents of translation keys or it is known issue with JS library. Unfortunately locale in format 'fr_FR' forces Symfony translations instead of CDN URL.

One possible solution can be:

$locale = $this->translator->getLocale();
$locale = \Locale::getPrimaryLanguage($locale);
curry684 commented 4 years ago

@freezy-sk does this stem from https://github.com/omines/datatables-bundle/pull/130?

curry684 commented 4 years ago

@jkabat can you elaborate more on the symptoms, do you get errors in the JS console?

jkabat commented 4 years ago

No, there are no errors. DT events in .then{} part of Promise simply does not fire. They are fired properly when CDN translations are used.

curry684 commented 4 years ago

Uh no clue then, waiting on @freezy-sk feedback.

freezy-sk commented 4 years ago

@curry684 I think that update of translations can't cause this issue. @jkabat could you please verify if it works correctly with 0.4.0?

jkabat commented 4 years ago

I'm using latest tagged version. I think #130 is not yet included in it, so issue is caused either by translations bundled with tagged version or by datatables JS library itself.

freezy-sk commented 4 years ago

@curry684 I've made simple test #139 to check if translations are rendered and escaped correctly and it looks ok

curry684 commented 4 years ago

Hmm indeed #130 is not tagged yet. If the language files are bugging out it might actually fix it as well. Can you try with dev-master @jkabat ?

jkabat commented 4 years ago

I have tried it and the result is the same... but after a second thinking I have to admit, that everything is probably OK and this issue can be closed.

When table is rendered with external language file, labels are updated and table events properly fired. On other hand, when translated labels are provided on table init, there is no need for firing DT events... and they are not.

This bundle issues POST on the first load of the page and all bound events on dynamic content are lost. I have wrongly expected to have either INIT or DRAW event fired after this POST. So now I have to find other way to reinitialize components (eg: filter input with datetime picker is not working unless I force table reload to have appropriate event fired....) Any ideas how to work around this issue?

jkabat commented 4 years ago

Actually it was frontend issue, sorry for spamming.

I've changed daterangepicker init from:

 $(this.selector).each(function(index) {

to

$('body').on('focus', this.selector, function() {