edo1z blog

プログラミングなどに関するブログです

cakePHP 2.3 JsヘルパーでAjaxなsubmitボタン

<?php echo $this->Js->submit('登録',array('update'=>'.add_result','url'=>'/vendors/add', 'with'=>'#add_form','class'=>'btn btn-primary'));?>
<?php echo $this->Js->writeBuffer(array('inline'=>false));?>

updateが、かえってきた内容の表示先。withは、対象formの指定。 これで、コントローラーで$this->dataでアクセスできるようになる。 便利過ぎ。

参考:http://book.cakephp.org/1.3/ja/The-Manual/Core-Helpers/AJAX.html