-
Notifications
You must be signed in to change notification settings - Fork 6k
fix (#1484 fixing 't.fn.datepicker is undefined' when loading bootstr… #2478
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from 3 commits
45a4d58
a9f104e
d2ea68b
6c1821a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,11 +6,11 @@ | |
|
||
(function(factory){ | ||
if (typeof define === 'function' && define.amd) { | ||
define(['jquery'], factory); | ||
define(['jquery'], factory(jQuery || window.jQuery || require('jquery'))); | ||
} else if (typeof exports === 'object') { | ||
factory(require('jquery')); | ||
factory(jQuery || window.jQuery || require('jquery')); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @jdnierth There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. facepalm you are correct it should throw an error in Node.js environment since there is no |
||
} else { | ||
factory(jQuery); | ||
factory(jQuery || window.jQuery); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. reverted this line to former factory(jQuery) |
||
} | ||
}(function($, undefined){ | ||
function UTCDate(){ | ||
|
@@ -89,6 +89,10 @@ | |
|
||
var Datepicker = function(element, options){ | ||
$.data(element, 'datepicker', this); | ||
|
||
this._events = []; | ||
this._secondaryEvents = []; | ||
|
||
this._process_options(options); | ||
|
||
this.dates = new DateArray(); | ||
|
@@ -98,7 +102,7 @@ | |
this.element = $(element); | ||
this.isInput = this.element.is('input'); | ||
this.inputField = this.isInput ? this.element : this.element.find('input'); | ||
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .btn') : false; | ||
this.component = this.element.hasClass('date') ? this.element.find('.add-on, .input-group-addon, .input-group-append, .input-group-prepend, .btn') : false; | ||
if (this.component && this.component.length === 0) | ||
this.component = false; | ||
this.isInline = !this.component && this.element.is('div'); | ||
|
@@ -308,8 +312,6 @@ | |
o.defaultViewDate = UTCToday(); | ||
} | ||
}, | ||
_events: [], | ||
_secondaryEvents: [], | ||
_applyEvents: function(evs){ | ||
for (var i=0, el, ch, ev; i < evs.length; i++){ | ||
el = evs[i][0]; | ||
|
@@ -465,7 +467,7 @@ | |
}, | ||
|
||
show: function(){ | ||
if (this.inputField.prop('disabled') || (this.inputField.prop('readonly') && this.o.enableOnReadonly === false)) | ||
if (this.inputField.is(':disabled') || (this.inputField.prop('readonly') && this.o.enableOnReadonly === false)) | ||
return; | ||
if (!this.isInline) | ||
this.picker.appendTo(this.o.container); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hey @ocarreterom , thanks for your comment but the UMD pattern is still in tact, the only change is to pass through variable declarations that can be different per environment. Happy to discuss if you have further feedback.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocarreterom I´m using this plugin in an AMD environment and it fails with the error message described in the bugs description without this line.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you test this line?
The second argument of
define([dependecies], callback)
should be a function (a callback likefactory
) to get the dependencies as params, not the result of the functionfactory()
.https://requirejs.org/docs/api.html#defdep
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @ocarreterom, I did within a custom application but I´ll decline this PR until I´ve made sure I rule out any other reason why I experienced this error. Thanks for your patience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@ocarreterom sorry I can`t decline this PR nor can I give it a label. In case you have more access permissions could you please put a label "on hold" on it? Many thanks in advance.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cc @vsn4ik