Вопрос

i am using :

  1. Boostrap V3.1.1
  2. Boostrap Datetimepicker (github link) (guide)

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)

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top