adinugro
(Adinugro)
March 8, 2011, 4:56am
1
Dear All,
I have a login dialog implemented using CjuiDialog. The dialog contains username (label+textfield), password(label+passwordfield), submit button. How could I set the focus on the username textfield when the dialog is open? Usually we can use tab to get make the first textfield active. Using dialog, I cannot use tab ;(
Cheers,
Daniel
tri
(tri - Tommy Riboe)
March 8, 2011, 10:56am
2
Daniel:
Dear All,
I have a login dialog implemented using CjuiDialog. The dialog contains username (label+textfield), password(label+passwordfield), submit button. How could I set the focus on the username textfield when the dialog is open? Usually we can use tab to get make the first textfield active. Using dialog, I cannot use tab ;(
Cheers,
Daniel
You can attach a handler to the dialogs open event
...
'options'=>array(
...
'open'=>'js:function(){$("#'.$dialog_id.' input:first").focus();}',
)
/Tommy
adinugro
(Adinugro)
March 8, 2011, 1:44pm
3
Hi Tommy,
I did it like this and still not working ;(
<?php
// for create
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
'id' => 'dialogAddAcc',
'cssFile'=>'jquery-ui.css',
'theme'=>'redmond',
'themeUrl'=>Yii::app()->request->baseUrl.'/css/ui',
'options' => array(
'title' => 'Create Account',
'show' => 'blind',
'hide' => 'explode',
'autoOpen' => false,
'modal' => true,
'width' => 750,
'open'=>'js:function(){$("#dialogAddAcc input:first").focus();}',
),
)); ?>
<div class="divForForm"></div>
<?php $this->endWidget(); ?>
What would be the problem?
cheers,
Daniel
tri:
You can attach a handler to the dialogs open event
...
'options'=>array(
...
'open'=>'js:function(){$("#'.$dialog_id.' input:first").focus();}',
)
/Tommy
tri
(tri - Tommy Riboe)
March 8, 2011, 2:52pm
4
Daniel:
Hi Tommy,
I did it like this and still not working ;(
<?php
// for create
$this->beginWidget('zii.widgets.jui.CJuiDialog', array(// the dialog
'id' => 'dialogAddAcc',
'cssFile'=>'jquery-ui.css',
'theme'=>'redmond',
'themeUrl'=>Yii::app()->request->baseUrl.'/css/ui',
'options' => array(
'title' => 'Create Account',
'show' => 'blind',
'hide' => 'explode',
'autoOpen' => false,
'modal' => true,
'width' => 750,
'open'=>'js:function(){$("#dialogAddAcc input:first").focus();}',
),
)); ?>
<div class="divForForm"></div>
<?php $this->endWidget(); ?>
What would be the problem?
cheers,
Daniel
I can’t tell. My suggested solution worked well in my case (IIRC, CActiveForm IIRC).
You should try to use divForForm in the selector instead of dialogAddAcc .
Also look for error messages in Firebug Console. Examine the generated html for clues how to modify the selector to address the input field.
/Tommy
Have you tried to register a news script like this?
<?php
$cs = Yii::app()->getClientScript();
$cs->registerScript(
'script-name',
'$("#dialogAddAcc").focus();',
CClientScript::POS_END
);
?>
greenius
(Steven)
August 11, 2011, 9:02am
7
I just had this same problem and discovered that removing the show option made the focus work properly.
With a show option (I was using ‘slide’) it seems to clear the focus when the effect finishes.