我在我的 CakePHP 应用程序中设置了就地编辑,除了一个问题外,它工作得很好。当数据成功发布到数据库时,返回值包括整个 'admin.ctp' 布局。我尝试了几件事$this->autoRender = false
,例如$this->layout = 'ajax'
但没有成功。请在下面输入我的代码:
jQuery 代码
$('.setting_value').editable('/settings/ajax_edit',{
id : 'data[Setting][id]',
name : 'data[Setting][value]',
select: true,
type : 'text',
cancel : 'Cancel',
submit : 'Save',
tooltip : 'Click to edit the title',
indicator: '<img src="/img/admin/ajax-loader.gif">'
});
我的控制器功能
public function ajax_edit(){
// $this->autoRender = false; // this doesnt seem to work
// $this->layout = 'ajax' // this does not work as well
if ($this->request->data) {
$this->Setting->id = $this->request->data['Setting']['id'];
$this->Setting->saveField('value', $this->request->data['Setting']['value']);
$this->set('newvalue', $this->request->data['Setting']['value']);
}
}
同样,一切都很好,但是当它返回更改的值时。