conflict between Cmenu.linkoption and datepicker

hello,

My problem is when i use option :"linkoption" http://www.yiiframew…nu#items-detail


$this->widget ( 'zii.widgets.CMenu', array (

					'items' => array (

							array ('label'=> 'Accueil','url'=> array ('/site/index')),

							array ('label'=> 'Note de frais','url'=> array ('/noteDeFrais/index'),'visible'=>!Yii::app()->user->isGuest),

							array ('label'=> 'Pole','url'=> array('/service/admin'),'visible'=>Yii::app()->user->checkAccess('admin')),

							array ('label' => 'Bareme des frais','url' => array ('/baremeFrais/admin'),'visible' => Yii::app ()->user->checkAccess ('admin')),

							array ('label' => 'Etat','url' => array ('/etat/admin'),'visible' => Yii::app()->user->checkAccess ('admin')),

							array ('label' => 'Profil','url' => array ('/salarie/view&id=' . Yii::app ()->user->id),'visible' => ! Yii::app ()->user->isGuest),

							//array ('label' => 'Statistique','url' => array ('/noteDeFrais/statistique'),'visible' => Yii::app ()->user->checkAccess ( 'chef' )),

							//array ('label' => 'Inscription','url' => array ('/salarie/create'),'visible' => Yii::app ()->user->isGuest),

							array ('label' => 'Login','url' => array ('/site/login'),'visible' => Yii::app ()->user->isGuest),

							array ('label' => 'Logout (' . Yii::app ()->user->name . ')','url' => array ('/site/logout'),'visible' => ! Yii::app ()->user->isGuest, 'linkOptions' => array('confirm' => 'Etes-vous sûr de vouloir vous déconnecter ?')), // this line !

					) 

			) );

my datepicker doesn’t work, but if i removed the confirm my datepicker works like a charm !

my datepicker code :




<script>

		$(function()

		{

			$( ".datepicker" ).datepicker({

			altField: "#datepicker",

			closeText: 'Fermer',

			prevText: 'Précédent',

			nextText: 'Suivant',

			currentText: 'Aujourd\'hui',

			monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],

			monthNamesShort: ['Janv.', 'Févr.', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil.', 'Août', 'Sept.', 'Oct.', 'Nov.', 'Déc.'],

			dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],

			dayNamesShort: ['Dim.', 'Lun.', 'Mar.', 'Mer.', 'Jeu.', 'Ven.', 'Sam.'],

			dayNamesMin: ['D', 'L', 'M', 'M', 'J', 'V', 'S'],

			weekHeader: 'Sem.',

			dateFormat: 'dd-mm-yy'

			});

		});

</script>

What happens ?

Ps : sorry for my english

Your datepicker function contains an error in the last line. Maybe that causes it, but can’t you check for javascript errors in your browser?

i have one error with firebug :


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

$( ".datepicker" ).datepicker({

but when i removed the confirmation on logout, my datepicker works ! And i haven’t this error :


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

$( ".datepicker" ).datepicker({

i don’t understand why when i put a confirmation on logout with no report with datepicker create an error !

i tried to load the script at the end with


<?php 

        Yii::app()->clientScript->registerScript('datepickerappel', "

                $('.datepicker').datepicker({

                        altField: '#datepicker',

                        closeText: 'Fermer',

                        prevText: 'Précédent',

                        nextText: 'Suivant',

                        currentText: 'Aujourd\'hui',

                        monthNames: ['Janvier', 'Février', 'Mars', 'Avril', 'Mai', 'Juin', 'Juillet', 'Août', 'Septembre', 'Octobre', 'Novembre', 'Décembre'],

                        monthNamesShort: ['Janv.', 'Févr.', 'Mars', 'Avril', 'Mai', 'Juin', 'Juil.', 'Août', 'Sept.', 'Oct.', 'Nov.', 'Déc.'],

                        dayNames: ['Dimanche', 'Lundi', 'Mardi', 'Mercredi', 'Jeudi', 'Vendredi', 'Samedi'],

                        dayNamesShort: ['Dim.', 'Lun.', 'Mar.', 'Mer.', 'Jeu.', 'Ven.', 'Sam.'],

                        dayNamesMin: ['D', 'L', 'M', 'M', 'J', 'V', 'S'],

                        weekHeader: 'Sem.',

                        dateFormat: 'dd-mm-yy'

                        });


        ", CClientScript::POS_READY); 

?>

but didn’t work :confused:

Are in both cases the same jquery.js file loaded? And are in both cases the same jqueryui.js loaded?

hi

check out firebug script tab and see jquery & jqueryUi is loaded.

you should add them to your layout(views/layouts/yourlayout.php)

yes in both cases I load the same jquery.js and jqueryui.js.

this is my layout :




<link rel="stylesheet" type="text/css"

	href="<?php echo Yii::app()->request->baseUrl; ?>/css/main.css" />

<link rel="stylesheet" type="text/css"

	href="<?php echo Yii::app()->request->baseUrl; ?>/css/form.css" />

<link rel="stylesheet"

	href="//code.jquery.com/ui/1.11.1/themes/smoothness/jquery-ui.css">

<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>

<link rel="stylesheet" href="/resources/demos/style.css">

	

use this code in your layout :




Yii::app()->clientScript->registerCoreScript('jquery');

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



instead of




<script src="//code.jquery.com/jquery-1.10.2.js"></script>

<script src="//code.jquery.com/ui/1.11.1/jquery-ui.js"></script>




change anything N-R :confused:

i always have the same error in firebug.

i think i will removed my confirm on logout and try another way to archieve that ! If you have any advice to do it in yii way ! :lol:

i try with http://www.yiiframework.com/wiki/438/jquery-ui-datepicker

Everything work like a charm !

thx everybody for your help :)