ajaxSubmitButton in a form rendered by ajax

I have a form which is rendered via ajax. I have ajaxSubmitButton in this form. Will this setup work? Its not working for me.

If I have the form already on the page upon initial page request, then ajaxSubmitButton works fine. I can also view the equivalent jquery code “jQuery(‘body’).undelegate…” at the bottom of the page in this case.

But in the first case, I dont find the equivalent jquery code in the DOM.

Using renderPartial? Make sure the processOutput param is set to true.

Great. Thanks. Setting processOutput to true fixed it.

Sorry how this could work, I’ve tried but failed, can you give an example of code ajaxsubmitbutton, RenderPartial order to be processed.

This code in the controller:

public function actionShow_Teach ()

{

$ nsearch= $ _POST [‘txt_search’];

$ this-> RenderPartial (‘teaching’, array (‘vsearch’ => $ nsearch), false, true);

Yii :: app () -> end ();

}

This code file to be in RenderPartial:

echo "<td>";

echo CHtml::ajaxSubmitButton(‘Save’,array(‘teach/get_teach’),array(‘update’=>’#view_teach’,),array(‘type’=>‘submit’,));

echo "</td>";

but,

I can’t view the equivalent jquery code “jQuery(‘body’).undelegate…” please helpme…thanks

This seems correct. What is the output of actionShow_Teach?

Can you give me the full code of view and controller file .

thanks before, this my code from view and controller file ,

[size="3"][color="#000080"]This Code in View/teaching, File name is views/index.php [/color][/size]

<?php

$this->breadcrumbs=array(

'Teaching',

);?>

<h1><?php echo $this->id . ‘/’ . $this->action->id; ?></h1>

<?php echo CHtml::beginForm(); ?>

<div class="row">

<?php echo CHtml::label(‘search for subjects :’, ‘lb_search_subject’); ?>

<?php echo CHtml::textField(‘txt_search’,’’,array(‘size’=>100,‘maxlength’=>50)); ?>

</div>

<?php

echo CHtml::ajaxSubmitButton(

'search object',


array('teaching/show_Teach'),


array(


	'update'=&gt;'#show_teach',


),


array(


	'type'=&gt;'submit',


)

);

?>

<?php echo CHtml::endForm(); ?>

<div id="show_teach">…show schedule…</div>

<div id="view_teach">…get schedule…</div>

=============================================================

[size="3"][color="#000080"]this controller file : file name : TeachingController.php [/color][/size]

<?php

class TeachingController extends Controller

{


public function actionIndex()


{


	&#036;this-&gt;render('index');


}





//view objects schedule


public function actionShow_Teach ()


{


&#036;nsearch= &#036;_POST ['txt_search'];


&#036;this-&gt; RenderPartial ('teaching', array ('vsearch' =&gt; &#036;nsearch), false, true);


Yii :: app()-&gt;end();


}





//get objects schedule


public function actionGet_teach ()


{


print_r(&quot;sucesss&quot;,true);	


Yii :: app()-&gt;end();


}

}

==================================================================

[size="3"][color="#000080"]and this is file to be renderpartial : filename views/teaching.php[/color][/size]

<?php

echo &quot;&lt;table border='1'aligment='center' bgcolor='#4F9BC6' width='100%'&gt;


&lt;tr&gt;


&lt;th&gt;Number&lt;/th&gt;


&lt;th&gt;Objects Code&lt;/th&gt;


&lt;th&gt;Objects&lt;/th&gt;	


&lt;th&gt;Lecturer&lt;/th&gt;


&lt;th&gt;SKS&lt;/th&gt;


&lt;th&gt;Class Name&lt;/th&gt;


&lt;th&gt;Capacity&lt;/th&gt;	


&lt;th&gt;Process&lt;/th&gt;


&lt;/tr&gt;&quot;;	


 	


&#036;n=0;


&#036;idchk=0;


	


&#036;tmpl=&quot;Select * from tbl_objects where objects like '%&#036;vsearch%'&quot;;


&#036;command-&gt;reset;


&#036;command = Yii::app()-&gt;db-&gt;createCommand(&#036;tmpl);


&#036;data=&#036;command-&gt;queryAll();


	


foreach(&#036;data as &#036;row):





&#036;idchk=&#036;idchk+1;


echo &quot;&lt;tr onmouseover=this.bgColor='lightblue' onmouseout=this.bgColor='#EFFDFF' bgcolor='#EFFDFF'&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;n=&#036;n+1 . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[kdx_objects] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[objects] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[lecturer] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[sks] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[class_name] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[capacity] . &quot;&lt;/td&gt;&quot;;   	





[color=&quot;#FF0000&quot;]echo &quot;&lt;td&gt;&quot;;


echo  CHtml::ajaxSubmitButton('Save',array('teaching/get_teach'),array('update'=&gt;'#view_teach',),array('type'=&gt;'submit',));


echo &quot;&lt;/td&gt;&quot;;   [/color]


   	


endforeach;


echo &quot;&lt;/table&gt;&quot;;

?>

thanks before, Show_Teach display on the index file in a div tag with id "show_teach" (<div id="show_teach"> … show schedule … </ div>)

this my code from view and controller file ,

[size="3"][color="#006400"]This Code in View/teaching, File name is views/index.php[/color][/size]

<?php

$this->breadcrumbs=array(

'Teaching',

);?>

<h1><?php echo $this->id . ‘/’ . $this->action->id; ?></h1>

<?php echo CHtml::beginForm(); ?>

<div class="row">

<?php echo CHtml::label(‘search for subjects :’, ‘lb_search_subject’); ?>

<?php echo CHtml::textField(‘txt_search’,’’,array(‘size’=>100,‘maxlength’=>50)); ?>

</div>

<?php

echo CHtml::ajaxSubmitButton(

'search object',


array('teaching/show_Teach'),


array(


	'update'=&gt;'#show_teach',


),


array(


	'type'=&gt;'submit',


)

);

?>

<?php echo CHtml::endForm(); ?>

<div id="show_teach">…show schedule…</div>

<div id="view_teach">…get schedule…</div>

=============================================================

[color="#006400"][size="3"]this controller file : file name : TeachingController.php[/size][/color]

<?php

class TeachingController extends Controller

{


public function actionIndex()


{


	&#036;this-&gt;render('index');


}





//view objects schedule


public function actionShow_Teach ()


{


&#036;nsearch= &#036;_POST ['txt_search'];


&#036;this-&gt; RenderPartial ('teaching', array ('vsearch' =&gt; &#036;nsearch), false, true);


Yii :: app()-&gt;end();


}





//get objects schedule


public function actionGet_teach ()


{


print_r(&quot;sucesss&quot;,true);   


Yii :: app()-&gt;end();


}

}

==================================================================

[color="#006400"][size="3"]and this is file to be renderpartial : filename views/teaching.php[/size][/color]

<?php

echo &quot;&lt;table border='1'aligment='center' bgcolor='#4F9BC6' width='100%'&gt;


&lt;tr&gt;


&lt;th&gt;Number&lt;/th&gt;


&lt;th&gt;Objects Code&lt;/th&gt;


&lt;th&gt;Objects&lt;/th&gt;   


&lt;th&gt;Lecturer&lt;/th&gt;


&lt;th&gt;SKS&lt;/th&gt;


&lt;th&gt;Class Name&lt;/th&gt;


&lt;th&gt;Capacity&lt;/th&gt;   


&lt;th&gt;Process&lt;/th&gt;


&lt;/tr&gt;&quot;;   


 


&#036;n=0;


&#036;idchk=0;


 


&#036;tmpl=&quot;Select * from tbl_objects where objects like '%&#036;vsearch%'&quot;;


&#036;command-&gt;reset;


&#036;command = Yii::app()-&gt;db-&gt;createCommand(&#036;tmpl);


&#036;data=&#036;command-&gt;queryAll();


 


foreach(&#036;data as &#036;row):





&#036;idchk=&#036;idchk+1;


echo &quot;&lt;tr onmouseover=this.bgColor='lightblue' onmouseout=this.bgColor='#EFFDFF' bgcolor='#EFFDFF'&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;n=&#036;n+1 . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[kdx_objects] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[objects] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[lecturer] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[sks] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[class_name] . &quot;&lt;/td&gt;&quot;;


echo &quot;&lt;td&gt;&quot; . &#036;row[capacity] . &quot;&lt;/td&gt;&quot;; 	 

[color="#FF0000"] echo "<td>";

echo  CHtml::ajaxSubmitButton('Save',array('teaching/get_teach'),array('update'=&gt;'#view_teach',),array('type'=&gt;'submit',));


echo &quot;&lt;/td&gt;&quot;;  [/color]


 	 


endforeach;


echo &quot;&lt;/table&gt;&quot;;

?>

Thank you… Let me try this…