ajax - Login with CakePHP and jQuery Mobile -


i'm building mobile application cakephp 2.3 , jquery mobile.

i'm having tough time making login work. send out links contain surveys, , if user not logged in on mobile browser, first makes them sign in.

the problem first time, refreshes blank page. if close page , reopen link, works, sucks. i'd redirect correctly.

here's view login:

<div class="users form">     <?= $this->session->flash('auth'); ?>     <?= $this->form->create('user'); ?>     <fieldset>     <?         echo $this->form->input('username');         echo $this->form->input('password');     ?>     </fieldset>     <?     $options = array(         'label' => 'login',         'rel' => 'external',         'data-ajax' => false     );     ?>     <?= $this->form->end($options); ?> </div> 

as can see, tried rel=external , data-ajax=false.

putting login on same page somehow might solve issue, seems defeats purpose of using cakephp in first place.

any ideas? i'm stumped.

that's not going create ajax form in cake.

you have disable default action of form, , submit data via javascript. can use built in jshelper in cake this.

to disable auto submitting of form need pass create method.

form->create('user',array('default'=>false)); ?>

you can use serializeform method of jshelper.

<?php $data = $this->js->get('#userform')->serializeform(array('isform' => true, 'inline' => true)); $this->js->get('#userform')->event(       'submit',       $this->js->request(         array('action' => 'save'),         array(                 'update' => '#userform',                 'data' => $data,                 'async' => true,                     'dataexpression'=>true,                 'method' => 'post'             )         )     ); ?> 

note: above requires place output jshelper in proper location of layout.

you can render form this.

<div class="users form">     <?= $this->session->flash('auth'); ?>     <?= $this->form->create('user',array('default'=>false)); ?>     <fieldset>     <?         echo $this->form->input('username');         echo $this->form->input('password');     ?>     </fieldset>     <?     $options = array(         'label' => 'login',     );     ?>     <?= $this->form->end($options); ?> </div> 

this off top of head. it's not test.


Comments

Popular posts from this blog

.htaccess - First slash is removed after domain when entering a webpage in the browser -

Automatically create pages in phpfox -

c# - Farseer ContactListener is not working -