yii-Verification code does not refresh automatically

Source: Internet
Author: User

The difference between render and renderpartial in Yii can explain why it is not refreshed.

650) this.width=650; "Title=" Yii High performance PHP framework "src=" Http://img.phperz.com/data/icon/14088060397715.png "alt=" 14088060397715.png "/>


When rendering the page output, the difference is:


1.render outputs the contents of the parent template, and embeds the rendered content into the parent template.
2.renderPartial does not output the contents of the parent template. The output is only for the local content of this rendering.

There is also an important difference:

The Processoutput ($output) function is executed by default inside the render function, which registers the components, such as CTreeView, inside the Cclientscript
The desired script for rendering output.

RenderPartial () does not automatically render the output client script by default, it needs to specify the parameters before output:
RenderPartial ($view, $data =null, $return =false, $processOutput =false)
Specifies that Processoutput is true.

For example, to local output CTreeView, with renderpartial for rendering, if the default Processoutput=false output content, does not contain client script
The output content is a normal UL list. No tree-shaped folding effect. After you have actively set Processoutput=true, all client-side scripts will be output in front of the list CTreeView required.

Here are a few of the related functions to use:

Render,renderpartial no longer introduce
Processoutput ()

<?phppublicfunction render ($view, $data =null, $return =false) {  if ($this->beforerender ($view )   {     $output = $this->renderpartial ($view, $data, True);     if (($layoutFile = $this->getlayoutfile ($this->layout))!==false)       $ output= $this->renderfile ($layoutFile, Array (' content ' = $output), true);     $this AfterRender ($view, $output);     $output = $this->processoutput ($output);     if ($return)       return  $output;    else       echo  $output;   }}publicfunction renderpartial ($view, $data = NULL, $return =false, $processOutput =false) {  if ($viewFile = $this->getviewfile ($view))!==false)   {     $output = $this->renderfile ($viewFile, $data, True);     if ($processOutput)        $output = $this->processoutput ($output);     if ($return)       return  $output;    else       echo  $output;   }  else    thrownewcexception (Yii::t (' Yii ', ' {controller} cannot find the requested view  ' {view} '. ',       array (' {controller} ' =>get_class ($this), ' {view} ' = $view))); Publicfunction processoutput ($output) {  yii::app ()->getclientscript ()->render ($output);   // if using page caching, we should delay dynamic  Output replacement  if ($this, $this->_dynamicoutput!==null&&  Iscachingstackempty ())   {     $output = $this->processdynamicoutput ($output);      $this->_dynamicoutput=null;  }   if ($this->_pagestates===null)      $this->_pagestates= $this Loadpagestates ();   if (!empty ($this->_pagestates))      $this->savepagestates ($this->_pagestates, $output);  return  $output;}

The above in the actual operation is still more useful, for example, you do not want to use large-form, you can directly transfer variables to the template, you can also make a number of variables into the module into the inside.


Background login Call Verification code, click the Verification code does not refresh, no response (all verification code configuration, parameters are correct). Find the wrong time to find that can refresh the verification code of the page than can not refresh the verification code of the page more than a section of JS code, to handle the Click Verification Code Refresh event.

Why is there a piece of code missing? The original is because the controller called RenderPartial and render respectively. Let's talk about the difference:

When rendering the page output.

Render outputs the contents of the parent template, and embeds the rendered content into the parent template.
RenderPartial does not output the contents of the parent template. The output is only for the local content of this rendering.
There is also an important difference:

The Processoutput ($output) function is executed by default inside the render function, which renders the output of the component, such as the required script that is registered in the CTreeView inside the cclientscript.

RenderPartial () does not automatically render the output client script by default, it needs to specify the parameters before output:
RenderPartial ($view, $data =null, $return =false, $processOutput =false)
Specifies that Processoutput is true.

Just like the problem we encountered, when using renderpartial, the page did not output the code to refresh the JS. So there's no response.


This article is from the "Mr_computer" blog, make sure to keep this source http://caochun.blog.51cto.com/4497308/1585325

yii-Verification code does not refresh automatically

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.