Cannot Render View With Form Ajax Validation When Using Jquerymobile

I am working on a jquerymobile project and am trying to use enableClientValidation=true and/or enableAjaxValidation=true on my CActiveForm to check user data against some rules in my model.

If I load the view url manually (index.php?r=log/checkin), validation works as expected. However, if I try to render the view from my controller, the view never loads. I’m simply stuck with the jquerymobile ajax loading icon. As soon as I disable jquerymobile, the render call in the controller works as expected.

Here are some relevant snippets:

View:




<?php

    $form = $this->beginWidget('CActiveForm',array(

        'action'=>$this->createUrl('//log/recordCheckin'),

        'id'=>'checkin',

        'enableAjaxValidation'=>false,

        'enableClientValidation' => true,

        'clientOptions' => array(

            'validateOnChange' => true,

            'validateOnSubmit' => true,

        )

    ));


    echo CHtml::activeTextField($model,'email',array(

                    'placeholder'=>$model->getAttributeLabel('email')

                ));

    echo $form->error($model,'email');


    $this->endWidget(); ?>



Controller:




    public function actionCheckin(){

        $model = $this->getModel();

        $this->render('checkin',array('model'=>$model));        

    }



Any ideas of why this is so and how to enable both jquerymobile AND ajax form validation so that I can actually launch my view from the controller? I’d highly appreciate any assistance on this. Thanks!

I believe jquery mobile use a concept of page inside html document preload all you contents on initial request and then organize them accordingly or you can do ajax call to load the stuff from controller

Thanks for the quick reply. I am not sure what you mean by preload on initial request. It sounds to me like Ajax is the way to go, but I am new to Ajax. Can someone point me in the right direction on how to load ajax to the controller?

Also, I have a similar problem - likey related: If I try to upload a photo, I get an error loading page (jquerymobile message) as soon as I try to upload a file using the $model->image->saveAs(’/path/to/file’); as explained in the Yii Wiki: How to upload a file using a model

It causes the error even when forcing my validation rule to safe. Of course, removing jquerymobile rectifies the issue but is not acceptable in my situation. If there are any examples out there for me to look at using jquerymobile with Yii (especially for the upload and ajax validation) I would greatly appreciate the links. Thanks!

¿Pudiste resolver el tema? Desde ya, muchas gracias!