How to disable click event in Javascript

I am displaying the chip list when the page is load in which by default click="FilterClasses" is placed . On the same page, I have simple HTML Buttons. When I click on the Button I want to remove the default attached CLICK EVENT.

<ejs-chiplist id="chip-filterTags" selection="Single" click="FilterClasses" cssClass="e-primary">

<e-chips>
@foreach (var product in (List<FilterTagInfo>)ViewBag.FilterTags)
{
<e-chip text="@product.Name" value="@product.FilterTagID" enabled="true"></e-chip>
}
</e-chips>
</ejs-chiplist>

Here is My HTML Button, When I click on the first button I want to remove the "click="FilterClasses"" event 


<button onclick="removeClickEvent()">Click me to remove Filter Event</button>

I have tried several ways to remove the event.
 
function removeClickEvent()
{
//$('#chip-filterTags).unbind("click");
//$('#chip-filterTags').off();
//$('#chip-filterTags').prop('onclick', null);
//$('#chip-filterTags').removeAttr("click");
//$('#chip-filterTags').event("click").off();
}

1 Reply

SS Sharon Sanchez Selvaraj Syncfusion Team September 20, 2021 10:50 AM UTC

Hi Harshida, 
 
Greetings from Syncfusion support. 
 
We have checked with your mentioned scenario. To remove the event listener on a button click, you can use the below way. 
 
Refer to the code snippet: 
 
document.getElementById("btn").onclick = function(){ 
    document.getElementById("chip-filterTags").ej2_instances[0].removeEventListener("click"); 
} 
 
Refer to the sample: 
 
 
Please get back to us if you need any further assistance. 
 
Regards, 
Sharon Sanchez S. 


Loader.
Up arrow icon