Reputation: 23515
i am using :
In my website the user can swap language. I need to change the language of the datetimepicker without reload the page. How can i do this? Do you have any suggestions?
EDIT:
At the beginning i am loading the right language using :
$('#banDateOneReal').datetimepicker({
isRTL: false,
autoclose: true,
language: lang,
});
The problem is to change the language after the creation of the object. Imagine lang was "en" and I want "fr" when the user click in a button.
Thanks you a lot for any help
(I am sorry about my poor english level)
Upvotes: 2
Views: 2220
Reputation: 23515
I have found a way! Thanks to DJDavid98 that gave to me some clues.
var tmp = $('#banDateOneReal').data('DateTimePicker').getDate();
$('#banDateOneReal').data('DateTimePicker').destroy();
$('#banDateOneReal').datetimepicker({
language: 'en',
});
$('#banDateOneReal').data('DateTimePicker').setDate(tmp);
This code is going to destroy the datepicker item and create a new one with the good language.
There is no function yet to refresh it without destruction.
Upvotes: 2