Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
99
rated 0 times [  100] [ 1]  / answers: 1 / hits: 27414  / 11 Years ago, fri, january 31, 2014, 12:00:00

I have Bootstrap datepicker with default format mm/dd/yyyy, and I have select where I can change
format from mm/dd/yyyy to dd/mm/yyyy and reverse.


On select change I want to my datepicker change format.


I tried


find('#options-date_format').on('change', function(){
$("#picker").datepicker({format: formatDate})
});

but It's not working, and I can't find way of doing this.
Also tried to remove / destroy datepicker but I got javascript error.


More From » jquery

 Answers
23

Ok I resolve this extending bootstra-datepicker.js



setFormat: function(format) {
this.format = DPGlobal.parseFormat(format);
}


And call that function



find('#options-date_format').on('change', function(){
$(#picker).datepicker('setFormat', newFormat);
});

[#72819] Thursday, January 30, 2014, 11 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
acaciac

Total Points: 317
Total Questions: 117
Total Answers: 128

Location: France
Member since Thu, Oct 27, 2022
2 Years ago
;