EasyUI Forum

General Category => EasyUI for jQuery => Topic started by: jrnfs on April 10, 2015, 07:43:53 AM



Title: setting the focus to textbox inside accordion onSelect event
Post by: jrnfs on April 10, 2015, 07:43:53 AM
Hi,
I have an accordion withing some textboxes. When I select a page I want to set focus to a specific textbox, like

<div class="easyui-accordion" data-options="onSelect:acc_select ... etc, etc...">
   <div title="user info" etc..>
      <input id='id_user' class="easyui-textbox" ...

function acc_select(title, index) {
   if (index = 0) {
      $('#id_user').textbox('textbox').focus();
   }
}


but nothing happen.
What am I doing wrong?
tks for any answer


Title: Re: setting the focus to textbox inside accordion onSelect event
Post by: stworthy on April 10, 2015, 08:05:00 AM
Some mistakes occur in your code, please try this:
Code:
function acc_select(title, index) {
   if (index == 0) {
      $('#id_user').textbox('textbox').focus();
   }
}


Title: Re: setting the focus to textbox inside accordion onSelect event
Post by: jrnfs on April 10, 2015, 08:19:34 AM
Tks for your answer.
Yes, the '=' is wrong, but it is not the real code, my mistake. It still don“t work.
I added a button to do the same code ($('#id_user').textbox('textbox').focus()) and it worked.
I guess there is something wrong with the event handler.


Title: Re: setting the focus to textbox inside accordion onSelect event
Post by: stworthy on April 10, 2015, 08:28:25 AM
Please refer to this example http://jsfiddle.net/fb273m03/


Title: Re: setting the focus to textbox inside accordion onSelect event
Post by: jrnfs on April 10, 2015, 08:42:47 AM
Solved, thank you so much.