Cjuidialog/cactiveform Client-Side Validation Problem

Hello.

Let me describe my problem. I think that this problem relates more to jQuery UI, but I want to discuss it with Yii community, maybe we’ll find right decision.

I have a form, that is copy of standart login form generated by Yii. I placed it in jQuery UI dialog using CJuiDialog. In CActiveForm I had add “‘enableClientValidation’=>true”. It works good in Firefox and Opera, but other browsers shows errors after Username field and highlights it. I think that blur event called after loading in browser.

I did found only one way for temporarily resolving this problem, when create event of the dialog occurs:




if($.browser.webkit || $.browser.msie){

  var isHandlerActive = false;

  $("#LoginForm_username").blur(function(e) {

    if (!isHandlerActive)

      e.stopImmediatePropagation();

      isHandlerActive = true;

  });

}



Full listing here of the view:




<?php

$this->beginWidget('zii.widgets.jui.CJuiDialog',array(

                'options'=>array(

                    'title'=>'Login',

                    'autoOpen'=>true,

                    'modal'=>true,

                    'show'=>'puff',

                    'hide'=>'slide',

                    'width'=>'350',

                    'height'=>'auto',

                    //'focusSelector' => 'submit',

                    'create'=> 'js:function(event, ui) {

                      if($.browser.webkit || $.browser.msie){

                        var isHandlerActive = false;

                        $("#LoginForm_username").blur(function(e) {

                          if (!isHandlerActive)

                            e.stopImmediatePropagation();

                          isHandlerActive = true;

                        });

                      }

                    }'

                ),

                ));

?>


<p>Please fill out the following form with your login credentials:</p>


<div class="form">

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

	'id'=>'login-form',

	'enableClientValidation'=>true,

	'clientOptions'=>array(

		'validateOnSubmit'=>true,

	),

)); ?>


	<p class="note">Fields with <span class="required">*</span> are required.</p>


	<div class="row">

		<?php echo $form->labelEx($model,'username'); ?>

		<?php echo $form->textField($model,'username'); ?>

		<?php echo $form->error($model,'username'); ?>

	</div>


	<div class="row">

		<?php echo $form->labelEx($model,'password'); ?>

		<?php echo $form->passwordField($model,'password'); ?>

		<?php echo $form->error($model,'password'); ?>

		<p class="hint">

			Hint: You may login with <tt>demo/demo</tt> or <tt>admin/admin</tt>.

		</p>

	</div>


	<div class="row rememberMe">

		<?php echo $form->checkBox($model,'rememberMe'); ?>

		<?php echo $form->label($model,'rememberMe'); ?>

		<?php echo $form->error($model,'rememberMe'); ?>

	</div>


	<div class="row buttons">

		<?php echo CHtml::submitButton('Login'); ?>

	</div>


<?php $this->endWidget('CActiveForm'); ?>

</div>


<?php $this->endWidget('zii.widgets.jui.CJuiDialog');?>



May somebody could provide nature interpretation of the work in such way in Chrome, Safari, IE. Maybe there are better ways for resolving. And may we include temporarily resolving of this pb in the Yii core and make request in jQuery UI community, if this is js bug only.

Thanks, Yuriy.