zoukankan      html  css  js  c++  java
  • 关于 yii 验证码显示, 但点击不能刷新的处理

    先说说 render 与 renderPartial, 各位看官, 先别走, 我没跑题, 这个问题如果需要解决, 关键就在 render 与 renderPartial 的区别. 

    renderPartial() 方法

    public string renderPartial(string $view, array $data=NULL, boolean $return=false, boolean $processOutput=false)
    $view string name of the view to be rendered. See getViewFile for details about how the view script is resolved.
    $data array data to be extracted into PHP variables and made available to the view script
    $return boolean whether the rendering result should be returned instead of being displayed to end users
    $processOutput boolean whether the rendering result should be postprocessed using processOutput.
    {return} string the rendering result. Null if the rendering result is not required.

    $view 常用的, 即返回给哪个视图模板

    $data 常用的, 即返回给视图模板时, 附带的数据

    $return 默认值是 false 一般不使用, 为false时, 渲染html页面;为true时, 会把html代码输出给你(如果你愿意的话, 可以接收这些html代码)

    $processOutput 默认值 false 一般不使用, 但本问题的关键也是这个参数了, 下面是这个参数的一些说明

    具体参见 http://www.yiichina.com/api/CController#processOutput-detail

    processOutput() 方法
    public string processOutput(string $output)
    $output string the output generated by the current action
    {return} string the output that has been processed.

    Postprocesses the output generated by render(). This method is invoked at the end of render() and renderText(). If there are registered client scripts, this method will insert them into the output at appropriate places. If there are dynamic contents, they will also be inserted. This method may also save the persistent page states in hidden fields of stateful forms in the page.

    个人理解, 就是指, 如果有注册的js css 时, 是否载入. 为 false 时, 不载入; true 时 载入.

    ===(以下是摘自互联网的一些关于此问题的说明)==============================================================

    原文 http://blog.sina.com.cn/s/blog_7d0c4ede0101glhk.html

    后台登陆调用验证码,点击验证码不刷新,没有反应(所有验证码配置,参数都是正确的)。找错的时候发现可以刷新验证码的页面比不可以刷新验证码的页面多了一段js代码,用来处理点击验证码刷新的事件。

    为什么会少了一段代码?原来就是因为控制器分别调用了renderPartial和render. 下面就说说它们的区别:

    在进行页面输出渲染的时候。

    render 输出父模板的内容,将渲染的内容,嵌入父模板。
    renderPartial 则不输出父模板的内容。只对本次渲染的局部内容,进行输出。
    同时还有个重要的区别:

    render 函数内部默认执行processOutput($output)函数, 会将把组件,比如 CTreeView 里面注册到CClientScript 里面的需要的脚本进行渲染输出。

    而renderPartial() 默认不自动渲染输出客户端脚本,需要进行参数的指定,才会输出:
    renderPartial($view,$data=null,$return=false,$processOutput=false)
    指定processOutput 为 true 即可。

    就像我们遇到的问题,用renderPartial时,页面没有输出验证码刷新的那段js。所以就没有反应。

    render 与 renderPartial 区别

    render 与 renderPartial 都属于 CController 里的方法

    yiichina

    renderPartial http://www.yiichina.com/api/CController#renderPartial-detail

    render http://www.yiichina.com/api/CController#render-detail

    blog

    http://tofar.blog.163.com/blog/static/20402210620126124311981/

  • 相关阅读:
    窗口设置背景图片
    双链表
    单链表
    Hough直线检测
    轮廓跟踪
    轮廓提取
    基于腐蚀的二值图像距离变换
    创建对话框用于交互
    hello world
    c#---params参数
  • 原文地址:https://www.cnblogs.com/debmzhang/p/3926795.html
Copyright © 2011-2022 走看看