Skip to content

Commit

Permalink
jquery date picker generates error if jQuery is not included #250
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtelnov committed Apr 27, 2021
1 parent 66598e2 commit 04b3dea
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions src/bootstrapdatepicker.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
function init(Survey, $) {
$ = $ || window.$;

if (!$.fn.bootstrapDP && !!$.fn.datepicker && !!$.fn.datepicker.noConflict) {
if (
!!$ &&
!$.fn.bootstrapDP &&
!!$.fn.datepicker &&
!!$.fn.datepicker.noConflict
) {
$.fn.bootstrapDP = $.fn.datepicker.noConflict();
if (!$.fn.datepicker) {
$.fn.datepicker = $.fn.bootstrapDP;
Expand All @@ -12,7 +17,7 @@ function init(Survey, $) {
title: "Date picker",
iconName: "icon-datepicker",
widgetIsLoaded: function () {
return !!$.fn.bootstrapDP;
return !!$ && !!$.fn.bootstrapDP;
},
isFit: function (question) {
return question.getType() === "bootstrapdatepicker";
Expand Down Expand Up @@ -111,7 +116,10 @@ function init(Survey, $) {
});

question.valueChangedCallback = function () {
pickerWidget.bootstrapDP("setUTCDate", !!question.value ? new Date(question.value) : "");
pickerWidget.bootstrapDP(
"setUTCDate",
!!question.value ? new Date(question.value) : ""
);
};
question.valueChangedCallback();
question.readOnlyChangedCallback = function () {
Expand Down

0 comments on commit 04b3dea

Please sign in to comment.