Hi everyone.
I am using the following code for creation my modal form on elgg.
echo elgg_view('output/url', [
'text' => ' ', //'text' => elgg_echo('add'),
'href' => 'ajax/view/forms/pessek_profile/'.$section.'?guidp='.$user_guid,
'class' => 'btn btn-primary btn-xs glyphicon glyphicon-plus elgg-lightbox',
'data-colorbox-opts' => json_encode(['maxHeight' => '85%', 'maxWidth' => '100%']),
]);
elgg_view_field(array(
'#type' => 'text',
'#label' => elgg_echo('gcconnex_profile:experience:country'),
'#help' => elgg_view_icon('help') . elgg_echo('gcconnex_profile:experience:country:help'),
'required' => true,
'name' => 'country',
'value' => $experience->country,
'class' => 'gcconnex-experience-country',
'onfocus' => true,
));
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- iionly@iionly
iionly - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
- ihayredinov@ihayredinov
ihayredinov - 1 like
- Hermand Pessek@rheman
Hermand Pessek - 0 likes
You must log in to post replies.Sorry I did a mistake it's
not
But nothing happen.
Did you make a mistake when posting you made a mistake? I think it has to be
For example the Elgg login form uses autofocus. If it doesn't work I can't tell why not. Except, maybe it's an Elgg issue as it seems the autofocus also doesn't work in the login dropdown (autofocus failing in lightbox maybe?).
Yes I did a Mistake when posting.
You are right iionly autofocus doesn't work in lightbox and I dont know why..
The binding is fired once at runtime, so there is no way it knows that a lightbox has opened and that an autofocusable input has been added to the DOM. IMO, that hack shouldn't even be in core, autofocusing a login form input that might be at the bottom of the page is really bad UX.
You can just use $.focus()
Thanks a lot for your explanation Ismayil Khayredinov . But where I am suppose to use $.focus()
Where you want it to execute
I dont understand.
I have created a modal form (using lightbox) and I need to set the focus by default to a given field of my modal form. I tried by using 'autofocus' => true,
Based on your explanation I understand why my code is not working.
In such case where I am suppose to use $.focus().
Best regard.
Are you expecting a working solution? Look into jQuery documentation, look at how plugins use AMD modules in combination with lightbox. It's really not that complicated, you may even learn something new
thanks