【问题标题】:Yii and ajax updating after submit does not render the update form page提交后更新 Yii 和 ajax 不呈现更新表单页面
【发布时间】:2014-04-07 18:17:08
【问题描述】:

我正在使用 Yii Mvc 框架并使用 ajax 和 PHP。 创建/保存评论后请求更新时,我无法使其工作。 我需要在创建/保存后刷新页面以使更新/保存工作。 我错过了什么?如何使点击事件不返回到最后一个控制器/动作 叫?提前感谢您的帮助。

步骤如下

                                                            **adresses called**
1. the user request the index page   (normal call)          /post/index
   (the page index is rendered)
2. the user click to create comment   (ajax call)     /post/createComment
   (the comment-form is rendered inside the index page)
3. the user click to save the comment (ajax call)           /post/saveComment  
   (the comment is saved and the comment-form is removed)
4. the user clcik to update the comment (ajax call)         /post/saveComment 
                                                            is called again
                                                            nothing happens

if before point 4 I refresh the page

4. the user click to update the comment (ajax call)         /post/updateComment
   (the comment-form with existing comment is rendered)

5. the user click to save the commnt (ajax call)            /post/saveComment
   (the comment is saved and the comment-form is removed)   --> ok

【问题讨论】:

    标签: jquery yii yii-routing


    【解决方案1】:

    通过 ajax 更新页面在 Yii 中不能自动工作。您可以使用 CActiveFrom 小部件及其 ajax 验证功能或使用 javascript 手动更新某些页面元素。如果您使用的是 CAtiveForm,我们需要查看视图和控制器源代码来帮助您。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-10-22
      • 1970-01-01
      • 2013-02-09
      • 1970-01-01
      • 2016-10-02
      相关资源
      最近更新 更多