CakePhp と JQuery Mobile を組み合わせて使用しようとしています。一般的にはうまく機能しますが、あるコントローラーから別のコントローラーへのリダイレクトを使用すると大きな問題が発生します。
特に RequestHandler を追加して以来。
この場合の問題は、Jquery Mobile がページ文字列全体を想定しているのに、コントローラーが単にビューを返していることだと思います。
jquery mobileでリダイレクト機能を動作させる方法はありますか?
この場合、Orderheads から Orderpositions にリダイレクトしたいと思います。
コントローラーのオーダーヘッド
if ($this->request->is ( 'post' )) {
$this->Orderhead->create ();
if ($this->Orderhead->saveAll ( $this->request->data,array (
'deep' => true
))) {
$orderId = $this->Orderhead->findByOrdernumber( $this->request->data['Orderhead']['ordernumber']);
$id =$orderId['Orderhead']['id'];
$this->Session->setFlash ( __ ( 'The orderhead has been saved.' ) );
return $this->redirect ( array (
'controller' => 'orderpositions',
'action' => 'add', $id
) );
} else {
$this->Session->setFlash ( __ ( 'The orderhead could not be saved. Please, try again.' ) );
}
}
コントローラの順序
public $components = array (
'Paginator',
'Session',
'RequestHandler'
);
public function add($id = null) {
if ($this->request->is ( 'ajax' )) {
if ($this->RequestHandler->isAjax ()) {
Configure::write ( 'debug', 0 );
}
if (! empty ( $this->data )) {
$this->autoRender = false;
$this->Orderposition->create ();
if ($this->Orderposition->save ( $this->request->data )) {
echo 'Record has been added';
} else {
echo 'Error while adding record';
}
}
} else {
$this->loadModel ( 'Orderhead' );
if ($this->Orderhead->exists ( $id )) {
$orderInformation = $this->Orderhead->findById ( $id );
} else {
throw new NotFoundException ( __ ( 'Invalid order id does not exists' ) );
}
$this->set ( compact ( 'orderInformation' ) );
}
}