0
I’m having this problem
Uncaught Typeerror: Cannot read Property 'locac' of Undefined
With the code:
function fnc(){
var evt = (window.event ? window.event : event);
var elemento = evt.target;
var params = $(elemento).data('params');
alert(params.locac);
}
$('body').on('click','button.inst',fnc);
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<button type="button" data-params='{"locac":"reg","titulo":"Inserir Registro"}' class="btn btn-success inst">Inserir</button>
Example link: example
But not always the error occurs, there are times I click on the button several times and does not give this error, more times I click once and already gives error.
Sometimes there’s a mistake and there’s no mistake.
The only mistake I see in real world
It’s always working right here for me, both in the snipper here in the OS, and in jsFiddle. (I’m testing in Chrome) for you it doesn’t work?
– Fernando Leal
I am in Chrome as well, within jsFiddle I realized that there is no error at any time for some reason inside the original code of the above mentioned error.. @Fernando
– Weliton Figueiredo
If the error is not reproducible it is complicated that someone can help you because it can be anything in your environment, and that is not accessible to us through the question. Even so, I will try to help, the first thing that comes to mind is jQuery’s version, which you are using?
– Fernando Leal
@Fernando Jquery2.1.3, and in this example I have an error because Firefox does not recognize Global Vent, I had to go through parameters, but this part this blz.
– Weliton Figueiredo