Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

browser textbox autocomplete event, when does this happen?

If i dont put autocomplete="off" on my <input type="text" />s the browser will sometimes fill them in with likely/remembered data.

When does this happen in the DOM-load-lifecycle?

It appears to be after:

$(function(){ alert('i happen before autocomplete'); });

Is there a dom-load event which occurs after form-autocompletion?

If so, what is it?

If not, meh, what can I do to execute some JS "on page load", but after autocompletion?

Solutions needs to be cross browser

Thanks

Andrew

like image 516
Andrew Bullock Avatar asked Nov 27 '25 21:11

Andrew Bullock


1 Answers

You could give $(window).load(callback) a try. This will wait until everything is fully loaded (images etc), rather than just after the DOM has been loaded the way $(document).ready does.

I'm not 100% sure whether or not it happens before auto complete but it definitely occurs after DOM ready.

Alternatively you might try registering a "one-off" change event handler when the DOM is ready like so:

$(document).ready(function() {
    $('input').one('click', function() { 
        // do whatever you wanted to do when it first changed
    });
});

This will fire only the first time the field changes. The only question is whether or not the browser will fire the change event when it does the autocompletion.

like image 114
TM. Avatar answered Nov 30 '25 09:11

TM.



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!