We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on: June 24, 2019).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

Set focus to input

Thread ID:

Created:

Updated:

Platform:

Replies:

144082 Apr 17,2019 02:13 PM UTC Apr 22,2019 11:26 AM UTC JavaScript - EJ 2 5
loading
Tags: AutoComplete
S_Line
Asked On April 17, 2019 02:13 PM UTC

Is there a way to set focus to the autocomplete input?

I have a autocomplete input inside a schedule and i want to set focus to the field when the popup is open.

Thank you

Gopi Govindasamy [Syncfusion]
Replied On April 18, 2019 07:46 AM UTC

Hi S_Line,  

Thanks for contacting us. 

We have checked your reported scenario for focusing the autocomplete component. We have provided public method for “focusIn” sets the focus to the component and for your scenario is schedule popup open focus the autocomplete. You can call the focusIn method in autoComplete created event or dialog open event after rendering the component. We have prepared test sample and code snippet for your reference.  
 
 

var autoObj = new ej.dropdowns.AutoComplete({ 
                    dataSource: members, 
                    fields: { value: 'text' }, 
                    floatLabelType: 'Always', placeholder: 'Team Members',  
                    created: function(){ 
                      autoObj.focusIn(); 
                    }  
                }); 
                autoObj.appendTo(inputEle); 


 
Regards, 
Gopi G. 


S_Line
Replied On April 18, 2019 11:16 AM UTC

Thank you for the solution, but, when i try to double click on cell and open up the schedule popup event, the input get highlighted, but, the cursor not ready to type.


Gopi Govindasamy [Syncfusion]
Replied On April 19, 2019 03:19 PM UTC

Hi S_Line,

 

Thanks for your update.

 

We have checked your scenario and the cause of the problem is autocomplete component render before popup open event, so dialog not opened and  element not append to DOM. In popupOpen event argument returned popup element and take the popup instance and bind the open event, call the autocomplete focusIn method. Please find code snippet and sample for your reference.

 

  args.element.ej2_instances[0].open = function() {

    autoObj.focusIn();

 }

 

 

Sample Link: https://stackblitz.com/edit/eoh4qc-qty2if?file=index.js

 

Regards,

Gopi G.


S_Line
Replied On April 22, 2019 11:21 AM UTC

Thank you very much! It's working now.

Prince Oliver [Syncfusion]
Replied On April 22, 2019 11:26 AM UTC

Hello S_Line, 

Most Welcome. We are glad to help you. 

Regards, 
Prince 


CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Please sign in to access our forum

This page will automatically be redirected to the sign-in page in 10 seconds.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

Live Chat Icon For mobile
Live Chat Icon