Pass a variable into JuiDialog


I use CGridView widget for listing some data. At the last column the three buttons are listed.

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








			'template' => '{update}{delete}{add}',

			'buttons' => array(


					'url'=>'Yii::app()->createUrl("/gallery/add", array("id" => $data->id))',


					'click'=>'js:function() { $("#gallery-add").dialog("open"); $("#gallery-add-form-field-parent").val("' . $data->id . '"); return false; }',





)); ?>

As you can see at the Add button I call the open dialog for displaying the JuiDialog. In that dialog I have a form for ajax request:

<?php $form=$this->beginWidget('CActiveForm', array(



)); ?>


	<?php echo $form->hiddenField($model,'parent', array('id'=>'gallery-add-form-field-parent')); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'name'); ?>

		<?php echo $form->textField($model,'name', array('autocomplete'=>'off')); ?>

		<?php echo $form->error($model,'name'); ?>



	<?php echo CHtml::ajaxButton(






			'beforeSend'=>'function() { 

				$("#resp").html("<img src=\"' . Yii::app()->createUrl('/images/loading.gif') . '\" />"); 









  	); ?>


  	<div id="resp"></div>

<?php $this->endWidget(); ?>

I need to pass into this form the Parent parameter for ajax sending. So I dont know how to pass $data->id into JuiDialog. $data->id works only in ‘url’ key of the buttons array, and in ‘click’ key it returns empty string.

I found one possible idea. I catch the id from the generated url:


	'url'=>'Yii::app()->createUrl("/gallery/add", array("id" => $data->id))',


	'click'=>'js:function() { 



		var rx = /=(\d+)$/;

		var arr = rx.exec($(this).attr("href"));




		return false; 



[font="Trebuchet MS"]great tricky man… i love it… this is solve my problem. is there another way to do this without tricky?

anyway thanks with this idea… very helping me.[/font]

I don’t know regular expression. Is there a normal way to solve this problem?