Stop events onblur onclick while loading

-1

Is there a way to stop the onblur events until the whole page loads?

The events are inside a normal html form and look like this

<input disabled type="text" name="art_siglas" id="art_siglas" onblur="Guardar()" placeholder="Siglas para etiquetas" title="Siglas para la etiqueta" />

And they auto complete with jQuery using this without document ready:

$('#art_siglas').val('<?=$DMo["siglas"]; ?>');
    
asked by Killpe 09.05.2017 в 19:19
source

1 answer

1

To make your JavaScript run after the page loads, remove the onblur you have in <input> like this:

<input disabled type="text" name="art_siglas" id="art_siglas" placeholder="Siglas para etiquetas" title="Siglas para la etiqueta" />

Create the onblur using JQuery after the page loads:

$(document).ready(function(){
   $('#art_siglas').blur(function(){
      // el código que tienes en GetBlur() va aquí
   });
   $('#art_siglas').val('<?=$DMo["siglas"]; ?>');
});

It can also be written like this, both forms are the same:

$(function(){
   $('#art_siglas').blur(function(){
      // el código que tienes en GetBlur() va aquí
   });

   $('#art_siglas').val('<?=$DMo["siglas"]; ?>');
});

When you do not need the blur you can call

$('#art_siglas').off( "blur" );
    
answered by 09.05.2017 в 23:24