我在一个可以编辑html内容的应用程序中工作。这是一个将文件内容放入textarea(文件获取内容)进行编辑的表单。有一个按钮发送文本区域的动作'编辑'和写入文件(文件放内容)
我的问题:
我想要第二个按钮,称为'预览',发送数据到动作'预览'和打开预览视图与提交的textdata内容。
我怎么能做到呢?
Thanks in advance
如果仅基于控制器和视图,则尝试如下:
在视图:echo $this->Form->submit('Send', array('class' => 'btntext_send', 'div' => false, 'name' => 'send'));
echo $this->Form->submit('Preview', array('class' => 'btntext_send', 'div' => false, 'name' => 'preview'));
在控制器:public function yourfunction(){
if($this->request->data['submit'] == 'send')){
// Your code
}elseif($this->request->data['submit'] == 'preview')){
// your code
}
}
为什么不使用JQuery将特定的行为绑定到特定的按钮?
$( '#button1' ).click(function() {
//do stuff
})
$( '#button2' ).click(function() {
//do other stuff
})