在我的程序中,我想在点击评论按钮时重新加载页面。究竟发生了什么,它确实更新了我的数据库中的数据,但我必须手动重新加载,而我想在我点击评论按钮后立即重新加载页面。
echo $this->Js->submit('Comment',
array(
'before' => $this->Js->get('#busy-indicator')->effect('fadeIn', array('buffer' => false)),
'complete' => $this->Js->get('#busy-indicator')->effect('fadeOut', array('buffer' => false)),
//'before'=>'alert("Comment posted");',
//'success'=>'jQuery("#PostComment").val("");',
'url' => array(
'controller' => 'posts',
'action' => 'comment/'.$post['Post']['id']
),
'update' => '#UserComment',
//'class'=>'submit',
'class' => 'comment',
'id'=>'SubmitComment',
));
答案 0 :(得分:0)
点击评论按钮后,您可以重定向到同一页面
返回$ this->重定向($ this-> here); OR
返回$ this->重定向($ this-> request-> here); // cake 2.x
假设我们在您的控制器中有一个函数处理注释
public function comment() {
// process content here...
// redirects the user immediately with a nice message
$this->flash('Your comment has been saved, thanks', '<page you wish to redirect');
OR
$this->setFlash('blablablabla');
return $this->redirect($this->here); // this->here refers to the current pageurl
OR
return $this->redirect($this->request->here); // cake 2.x (// this->request->here refers to the current pageurl)
}