You need to sign in to do that
Don't have an account?
Lukesh Karmore
can someone ans me, in which condition we use this keyword "event"
can someone ans me, in which condition we use this keyword "event" see below...... in handleChange we use word event and in handleClick we not why
handleChange(event){
this.searchvalue=event.target.value;
}
handleClick(){
if(this.checkError()){
InputContacts({searchKey:this.searchvalue})
.then(result=>{
this.contacts=result;
this.error=undefined;
})
.catch(error=>{
this.error= error;
this.contacts=undefined;
});
}
else{
alert('input should be valid');
}
}
Thank You
handleChange(event){
this.searchvalue=event.target.value;
}
handleClick(){
if(this.checkError()){
InputContacts({searchKey:this.searchvalue})
.then(result=>{
this.contacts=result;
this.error=undefined;
})
.catch(error=>{
this.error= error;
this.contacts=undefined;
});
}
else{
alert('input should be valid');
}
}
Thank You
>> https://salesforce.stackexchange.com/questions/285295/lwc-events-when-to-use-event-target-value-event-detail-value
You can check the above implementation as it mentions when to use event.target.value & event.detail.value
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.
This event is actually an object containing information about the action that just happened. And passing that as a parameter in handler function is optional. In your code, "handleChange(event)" handler needed the element on which the action (event) happened (event.target.value) and hence the event parameter is passed. If you dont need the action (event) details, you dont need to pass.
Hope this helps!
(like onchange) we have to use event keyword in handlers right malni.
So basically when an onchange event or any such event is triggered an event object containing all the parameters is sent to the function so you can use this event object inside the function as a parameter to access these values so that it can be used inside the function.
You can read more in regards to events in JS in this link (https://developer.mozilla.org/en-US/docs/Web/API/Event).
Let me know if it helps you and close your query by marking it as solved so that it can help others in the future.
Thanks.