$.datepicker not defined

与世无争的帅哥 提交于 2019-12-11 23:21:09

问题


I cannot coax the datetimepicker to work. Datepicker works fine. But the add-on has not worked after about 7 hours of attempts.

Firebug shows no 404's.

All jQuery libraries are included with the theme framework as well.

I tried replacing all instances of $.datepicker with jQuery.datepicker in the script. This made no difference.

I tried moving scripts above or below or combining them. The same error persists. I have examined several related answers in this forum and many, many others to no avail. I have reviewed jQuery literature but it does not address this specific problem..

My code is this. Just a couple of html inputs. Datepicker works fine.

   `jQuery(document).ready(function(){
    jQuery('#datepicker').datepicker();
});

jQuery(document).ready(function(){
    jQuery('#datetime').datetimepicker();
});`

This segment of code works fine. Datetimepicker then hits the line

$.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {

$.datepicker not defined.

If you do not know the answer, perhaps there is a way for javascript/jQuery to produce more detailed information about its failures?


回答1:


Change to this

jQuery(document).ready(function(){
        $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings){};
});

Looks like you are trying to call the function before it gets loaded. Jquery will go through each doc.ready function in order, so as long as this is after the initial load it should work.

Also, use chrome's built in develop tools for debugging purposes. Ctrl-shift-j on a PC will open them up, you can see the console messages to figure out whats going on.

heres a jsfiddle to show the working syntax http://jsfiddle.net/XA79k/




回答2:


( function($$) {


$$(document).ready(function(e) {
        $.datepicker.parseDateTime = function(dateFormat, timeFormat, dateTimeString, dateSettings, timeSettings) {
});

} ) ( jQuery );

I had similiar issues and had to do it this way since there was conflicts. And I tried jQuery.noConflict() aswell, but didnt work. Above code worked for me.



来源:https://stackoverflow.com/questions/11599063/datepicker-not-defined

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!