EasyUI Forum
April 27, 2024, 04:46:35 PM *
Welcome, Guest. Please login or register.

Login with username, password and session length
News:
 
   Home   Help Search Login Register  
Pages: [1]
  Print  
Author Topic: Get Focus to move from button to text field on opened dialog  (Read 6154 times)
Swany
Newbie
*
Posts: 44


View Profile Email
« on: July 06, 2018, 01:23:16 PM »

How do I get the textbox on an open dialog to take focus. I have a eui-linkbutton in which I open a modal eui-dialog which has an eui-textbox on it. The focus stays on the button in which I opened the dialog with. I cannot programmatic seem to get the focus to move to dialog's textbox.

Any help would greatly be appreciated.
Logged
jarry
Administrator
Hero Member
*****
Posts: 2262


View Profile Email
« Reply #1 on: July 06, 2018, 07:17:39 PM »

After opening the dialog, the 'open' event fires. You can call 'focus' method to focus on the textbox component.
Code:
@Component({
selector: 'app-root',
template: `
<eui-linkbutton (click)="dlg.open()">Open</eui-linkbutton>
<eui-dialog #dlg [title]="'dialog'" [closed]="true" (open)="onOpen()" [bodyStyle]="{padding:'20px'}">
<eui-textbox #tb></eui-textbox>
</eui-dialog>
`
})
export class AppComponent {
@ViewChild('tb') tb: TextBoxComponent;
onOpen(){
setTimeout(() => this.tb.focus())
}
}
Logged
Swany
Newbie
*
Posts: 44


View Profile Email
« Reply #2 on: July 09, 2018, 11:41:19 AM »

Works great!

Thanks Jarry
Logged
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines Valid XHTML 1.0! Valid CSS!