jQuery UI Widgets › Forums › General Discussions › Angular › Jqxbutton inside jqxWindow focus is not working
This topic contains 3 replies, has 2 voices, and was last updated by Martin 7 years, 8 months ago.
-
Author
-
Hi,
I am using jqxbuttons ok and cancel inside jqxWindow.
I am trying to set focus to ‘ok button’.
@viewChild(‘ok’) okButton: jqxButtonComponent;
this.okButton.focus();Focus is not setting in the corresponding button.
Kindly provide any solution.
Thenkas & Regards,
GoviHello Govi,
Here is a simple Demo that shows how to set focus to the button.
Your selection with ViewChild is correct. You should just move the ‘focus’ method in ngAfterViewInit lifecycle hook because the elements are not created before that.Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/Hi Martin,
Thanks for ur response.
I tried your solution. Focus is setting in the button.On ok button click I written code to close the window. But When I press Enter, Window is not closing.
Guess focus is in window.<jqxWindow #window
[width]=”500″
[height]=”400″
[minHeight]=”300″ [minWidth]=”300″
[isModal]=”true” [autoOpen]=”false”>
<jqxButton #okButton (click)=”closeWindow($event)” [width]=”100″>OK</jqxButton>
<jqxButton #cancelButton [width]=”100″>Cancel</jqxButton>
</jqxWindow>TS:
export class AppComponent {
@ViewChild(‘okButton’) onButton: jqxButtonComponent;
@ViewChild(‘window’) windowRef: jqxWindowComponentopenWindow(e){
this.onButton.focus();
e.stopPropagation();
this.windowRef.open();
}
closeWindow(e){
this.windowRef.close();
}
}Thanks & Regards,
GoviHello Govi,
I’ve updated the Demo , adding the closeWindow function.
When opening the window you should call the button’s focus method after this.windowRef.open(); and also put it in a setTimeout with 100 or more miliseconds, so it is executed after the window is opened.
Best Regards,
MartinjQWidgets Team
http://www.jqwidgets.com/ -
AuthorPosts
You must be logged in to reply to this topic.