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. Image for the cookie policy date

Close the suggestion list


I created an autocomplete with datasource on server side.
if the value does not exist (check in on focus out), i open a modal dialog for create a new value.

if the user write a new value and click (not with tab) on other field, the suggestion list can open but it will not close.
How can we to force by javascript to close the suggestion list?

i try $(this.elementId).ejAutocomplete("close");
but i receive an exception.


3 Replies

RJ Rekha J Syncfusion Team January 30, 2017 11:12 AM UTC

Hi Mickael,   
Thanks for contacting Syncfusion Support.   
To achieve your requirement, we have provided a workaround solution. That is, you have to use CSS for suggestionList “display:none” when the suggestionList needs to be closed.    
We have created a simple sample to achieve your requirement. In our sample, we have two buttons. One button is used to open the suggestionList. Another button is used to hide the suggestionList. Both actions are done by using click event of the buttons.   
You can download the sample from this link:   

DA Dan November 30, 2018 03:36 PM UTC

This doesn't appear to work when coming back from an AllowAddNew() call. The suggestion list remains open. I'm using EJ1 with MVC, version Code looks like this Any suggestions on how to get the suggestion list to close up after the item gets added on the server? Thanks.

                .Datasource((IEnumerable<Specialty>) ViewData["Specialties"])
                .AutocompleteFields(f => f.Text("Name").Key("Id"))
                .ClientSideEvents(c => c.Select("onSpecialtySelect"))
                .HtmlAttributes(new Dictionary<string, object> {{"name", "Specialties"}})

    function onSpecialtySelect(args){ 
        if(args.text.indexOf('Add New') >= 0){ 
            var newval = args.text.replace('(Add New)',''); 
                url: '@Url.Action("AddSpecialty", "Contact")', 
                data: { specialtyName: newval.trim() }, 
                type: 'POST', 
                dataType: "json", 
                success: function (response) { 
                    var ac = $("#Specialties").ejAutocomplete("instance"); 
                    ac.suggestionList.css("display", "none");

        public ActionResult AddSpecialty(Specialty model, string specialtyName)
            var dbContext = new MyDbContext();
            var specialty = new Specialty {Name = specialtyName };

            return Json(dbContext.Specialties.ToList());

    public class Specialty {
        public int Id { get; set; }
        public string Name { get; set; }

DL Deepa Loganathan Syncfusion Team December 5, 2018 07:36 AM UTC

Hi Dan,  
We regret the delay in reply. 
We have analyzed your query and have updated the solution based on the analysis in an incident under your direct-trac account. Please follow up the incident for more details.  
Please click here to login to your Direct Trac login with the below link.  
Deepa L. 

Live Chat Icon For mobile
Up arrow icon