ejs-autocomplete event on clearing text

Hi,

I would like to listen event on the clearing text from the autocomplete. 


I would like to perform some action once text is cleared from the field. 

Regards,
Parth

3 Replies 1 reply marked as answer

BC Berly Christopher Syncfusion Team June 3, 2021 07:19 AM UTC

Hi Parth, 
  
Greetings from Syncfusion support. 
  
By default, while changing the value from the AutoComplete component either by backspace, selection or clear value using clear icon, then the change event of the component will be triggered.  
  
  
Else, if you want to capture the event when you clear the values using clear icon, we suggest you to bind the event for the clear icon as mentioned in the below code example. 
  
  ngAfterViewInit() { 
    this.localObj.element.addEventListener('input'e => { 
      if (!this.isFirst) { 
        this.isFirst = true; 
        this.localObj.element.parentElement 
          .querySelector('.e-clear-icon') 
          .addEventListener('mousedown'args => { 
            console.log('Clicked on clear icon'); 
          }); 
      } 
    }); 
  } 
 
  
  
Regards, 
Berly B.C 


Marked as answer

PK Parthkumar Kakadiya June 4, 2021 09:20 AM UTC

Hi Berly,

Thanks a lot. your solution worked for me. 

Regards,
Parth


BC Berly Christopher Syncfusion Team June 4, 2021 01:21 PM UTC

Hi Parthkumar, 
  
Most welcome. Please let us know if you need further assistance on this. 
  
Regards, 
Berly B.C 


Loader.
Up arrow icon