ajaxLink $ajaxOptions 'update' parent window?

How do i specify the parent window on ‘update’ ajaxOption ???




echo CHtml::ajaxLink(

                     'Delete from project',

                      array('link/DelFromProject'),

                      array(

                            'update' => '#index',

                            'type'=>'POST',

                            'data'=>array( 

                                         'id_link'=>CHtml::encode($data->id_link),

                                         'id_project'=>CHtml::encode($_REQUEST['id_project'])

                                         ) 

                            )

                     );






When you use ajax links like that you have to create a div and replace his content.

This is the tipical scenario:

In the view:




<div id="index">

    <?php $this->renderPartial('_subview');?>

</div>



The ajax link:




<?php echo CHtml::ajaxLink(

   [...]

   array(

      'update' => '#index',

   )

);?>



And the controller will do a render partial on the subview, not on the whole view.

If you have to replace the whole view you can create the div in layout/main around $content




<div id="difForAjaxReplaceOfTheWholeView">

    <?php echo $content?>

</div>




Yes i understand that but i got two problems… first is i want to update the window.parent.document because i’m opening a lightbox with iframe and when i click a ajaxlink inside that iframe i want to update content of parent window.

I know jQuery parameter ‘success’ can do that like this:




'success' => 'function(data) 

{

    $("#teste", window.parent.document).html("File '.$id_file.' added with success to project '.$id_project.'"); 

    $("#index").html(data);

}'



But i want this on ‘update’ or ‘replace’ parameters…

Second problem is that on the parent window i got the list of Files added to that project. All File got an ajax link to delete the file from the project… the problem is when i 1 link is ok… when i click the second time after page was rendered i got an error:

CDbException

Description

CDbCommand failed to execute the SQL statement: SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘’ at line 1

Source File

C:\Projectos\MyLittleSystem\framework\db\CDbCommand.php(375)

Just for the record, CHtml itself uses ‘success’




if(isset($options['update']))

{

	if(!isset($options['success']))

		$options['success']='js:function(html){jQuery("'.$options['update'].'").html(html)}';

	unset($options['update']);

}

if(isset($options['replace']))

{

	if(!isset($options['success']))

		$options['success']='js:function(html){jQuery("'.$options['replace'].'").replaceWith(html)}';

	unset($options['replace']);

}



/Tommy

But it dont allow second parameter like:

("#contentDiv", window.parent.document)

right’?