TypeError: $ (...). Datepicker is not a function

I am using the Yii Framework for application development. I use

$(document).ready(function(){

    $('.date-picker').datepicker();

});

it works everywhere, but when I put it in the index.php view file, it gives me the following error in the firefox console:

TypeError: $ (...). datepicker is not a function

$ ('DatePicker.) DatePicker () ;.

I searched for the error above, but in my criteria from stackoverflow and other blogs for this request no solutions are applicable.

thanks

+4
source share
3 answers

Try including jquery library files on the watch page. I had the same problem two weeks ago, but when I named it separately, my problem was resolved.

<?php
Yii::app()->clientScript->registerCoreScript('jquery');
Yii::app()->clientScript->registerCoreScript('jquery.ui');

Yii::app()->clientScript->registerScriptFile(Yii::app()->baseUrl .'/js/jquery.ui.datepicker.js'); ?>
+4

, , noConflict() jQuery. Wordpress:

jQuery, WordPress, ​​ noConflict()mode (. wp-includes/js/jquery/jquery.js). JavaScript, WordPress .

noConflict() $shortcut jQuery .

$ jQuery, .

:

jQuery(document).ready(function() {
  jQuery('.date-picker').datepicker();
});

$, , :

jQuery(document).ready(function($) {
  $('.date-picker').datepicker();
});
+2

Yii Frameworkdo not provide a default datepicker parameter. You should either use any extensions for datepicker.

Mark the extension of the date picker for the yii frame . Also check jQuery-ui datepicker in Yii structure

0
source

All Articles