EasyUI Forum

General Category => General Discussion => Topic started by: manojvijayan on December 24, 2012, 01:03:12 AM



Title: element.focus is not working
Post by: manojvijayan on December 24, 2012, 01:03:12 AM
Hi,

Please see the url:
http://cochinwebdesign.com/dance/admin/

username :admin
password: admin

Select any of one link from left, then press add button on top of the screen.
document.form.name.focus() and $('#mainForm')[0].focus(); both are not working.

Could u please provide some sample code?

Thanks in advance..................



Title: Re: element.focus is not working
Post by: stworthy on December 24, 2012, 02:39:41 AM
The simple way to solve your problem is to override your 'loadPage' function as below:
Code:
function loadPage(url,a,contentPanel){
//...
var p = $('#'+contentPanel);
p.panel('options').onLoad = function(){
$('#mainForm').find('input[name=title]').focus(); // here is the focus code
};
p.panel('refresh',url);
//...
}

Another way is to add the following code snippets in your php file that will be loaded.
Code:
<script>
$('#mainForm').find('input[name=title]').focus();
</script>


Title: Re: element.focus is not working
Post by: manojvijayan on December 24, 2012, 05:16:44 AM
Thanks  stworthy .

The first option is working.