CJuiDialog Error Question

Does anyone know why this code with the CJuiDialog widget does not cause an error




<script type="text/javascript">

//Inventory Details

$(function() {

	var $dialog = $('<div id="inventory-details"></div>');

	$dialog.dialog({

		title: 'Show data',

		autoOpen: false,

		modal: true,

		//position: ['center', 'top'],

		width: 'auto',

		height: 'auto',

	});


	$('table.items a').click(function() {

		$dialog.load($(this).attr('href')).dialog('open');

		return false;

	});

		

	$('.ui-widget-overlay').live('click', function() {

		$('#inventory-details').dialog( "close" );

	});

});

</script>

<h1>Current Inventory</h1>

Please check our inventory regularly to see our current offerings.


<?php 

	/*$this->widget('zii.widgets.CListView', array(

		'dataProvider'=>$dataProvider,

		'itemView'=>'_view',

	));*/


	$this->beginWidget('zii.widgets.jui.CJuiDialog',array(

			'id'=>'juiDialog',

			'options'=>array(

			'title'=>'Show data',

			'autoOpen'=>false,

			'modal'=>true,

			'width'=>'auto',

			'height'=>'auto',

			),

		));

	$this->endWidget();

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

		'dataProvider'=>$dataProvider,

		'template' => "{pager}\n{items}\n{pager}",

		'ajaxUpdate' => false,

		'pager'=>array(

	'header' => '',

	'prevPageLabel'  => '< previous',

	'nextPageLabel'  => 'next >',

),


		'columns'=>array(

			

array(

				'name'=>'',

				'type'=>'html',

				'value'=>'CHtml::link(CHtml::image(Yii::app()->baseURL.\'/images/inventory/thumb/\' . $data->thumb),array(\'/inventory/\'.$data->id))',

				),

			array(

				'name'=>'make',

				'type'=>'html',

				'value'=>'CHtml::encode($data->make) . CHtml::tag(\'br\') . CHtml::encode($data->body) . CHtml::tag(\'p\') . CHtml::link("View Details" ,array(\'/inventory/\'.$data->id))',

			),

			'model',

			'engine',

			'trans',

			array(

				'name'=>'Stock Number',

				'type'=>'html',

				'value'=>'"JD" . CHtml::encode($data->id)',

			),

			'price',

			

			

		),

	));

	

?>	



while this code without it causes a $dialog.dialog is not a function error?




<script type="text/javascript">

//Inventory Details

$(function() {

	var $dialog = $('<div id="inventory-details"></div>');

	$dialog.dialog({

		title: 'Show data',

		autoOpen: false,

		modal: true,

		//position: ['center', 'top'],

		width: 'auto',

		height: 'auto',

	});


	$('table.items a').click(function() {

		$dialog.load($(this).attr('href')).dialog('open');

		return false;

	});

		

	$('.ui-widget-overlay').live('click', function() {

		$('#inventory-details').dialog( "close" );

	});

});

</script>

<h1>Current Inventory</h1>

Please check our inventory regularly to see our current offerings.


<?php 

	/*$this->widget('zii.widgets.CListView', array(

		'dataProvider'=>$dataProvider,

		'itemView'=>'_view',

	));*/


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

		'dataProvider'=>$dataProvider,

		'template' => "{pager}\n{items}\n{pager}",

		'ajaxUpdate' => false,

		'pager'=>array(

	'header' => '',

	'prevPageLabel'  => '< previous',

	'nextPageLabel'  => 'next >',

),


		'columns'=>array(

			

array(

				'name'=>'',

				'type'=>'html',

				'value'=>'CHtml::link(CHtml::image(Yii::app()->baseURL.\'/images/inventory/thumb/\' . $data->thumb),array(\'/inventory/\'.$data->id))',

				),

			array(

				'name'=>'make',

				'type'=>'html',

				'value'=>'CHtml::encode($data->make) . CHtml::tag(\'br\') . CHtml::encode($data->body) . CHtml::tag(\'p\') . CHtml::link("View Details" ,array(\'/inventory/\'.$data->id))',

			),

			'model',

			'engine',

			'trans',

			array(

				'name'=>'Stock Number',

				'type'=>'html',

				'value'=>'"JD" . CHtml::encode($data->id)',

			),

			'price',

			

			

		),

	));

	

?>	



jquery-ui.js isn’t rendered automatically when jui widget isn’t used. Most probably this is the case.

Thanks.

When I add


<script type="text/javascript" src="<?php echo Yii::app()->baseUrl; ?>/js/jquery-ui-1.8.16.custom/js/jquery-ui-1.8.16.custom.min.js"></script>

this solves the problem.

I would have thought


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

on the view page would have done the same thing. Is there another Yii way to call in jQuery?




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



Because the dialog is a jquery-ui component, so you’ll need both, jquery + jquery-ui

I have added both to my view page


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

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

but I still receive the jQuery error.

if u look in the source code, does the jquery-ui.js library gets referenced in a script src tag ?

No.

If I call zii.widgets.jui.CJuiDialog then the jquery-ui loads.

My bad, i just now saw the issue, actually it is:




registerCoreScript('jquery.ui');

NOT

registerCoreScript('jquery-ui');



Thanks.