I need to check if a View exists on an OnClick event that runs the test function
if($.minhaview.propriedade == 'teste'){
alert("existe um evento onClick com o valor teste");
}
I need to check if a View exists on an OnClick event that runs the test function
if($.minhaview.propriedade == 'teste'){
alert("existe um evento onClick com o valor teste");
}
If you added an element to onclick
property, you can test it, for example:
if ($.minhaview.onclick) {
// faça algo...
}
But if you added the event with addEventListener('click', evento)
ai the answer is: you can not check if there is an event in this element.
The observer that manages element events in javascript only allows you to add and remove events, but does not expose the list of events.
However, you can modify this behavior by modifying the event prototype, just as jQuery does.
You could create a way to store in some object property the list of events contained in it. But by default the W3C specification does not provide such exposure.
If you just want to test whether the variable already has the value of an assigned function, you can use the typeof function.
if(typeof $.minhaview.propriedade === 'function')
{
// ...
}