uxsolutions / bootstrap-datepicker

A datepicker for twitter bootstrap (@twbs)
Apache License 2.0
12.65k stars 6.08k forks source link

Bootstrap datepicker conflicting jQuery UI datepicker #2219

Open pnaw94 opened 7 years ago

pnaw94 commented 7 years ago

I'm using both jQuery UI and bootstrap-datepicker. All the dependencies are loaded automatically, and I don't have any room for manual scripting in-between to assign those to some variables.

The problem is that jQuery UI's datepicker replaces bootstrap-datepicker (the $.fn.datepicker variable), so that I can not set additional languages (and I need to add some other than the ones shipped with datepicker distribution).

There's this answer: https://github.com/uxsolutions/bootstrap-datepicker/issues/1694, although I can't really see how this is any helpful, since on page load jQuery UI already replaces $.fn.datepicker, I also have no access to $.fn.datepicker.noConflict method.

Is there something I'm missing, or maybe another way to access bootstrap-datepicker?

kevyworks commented 6 years ago

I am having same issues as-well, i have to use [data-provide] I would suggest to add the datepickerPlugin as $.datepickerPlugin, but do this for the moment:

$('[data-provide="datepicker-inline"]:not([datepicker-binded])').each(function () {
  $(this).attr('datepicker-binded', true); // for pjax
  var config = JSON.parse($(this).attr('data-datepicker-options'));

  if (!$.isPlainObject(config)) {
    config = {};
  }

  var dp = $(this).data('datepicker');

  if ('_process_options' in dp) {
    dp._process_options($.extend({}, config, {autoclose: true}));
  }
});