Andrew Bullock
Andrew Bullock

Reputation: 37378

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

Upvotes: 3

Views: 1407

Answers (1)

TM.
TM.

Reputation: 111027

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.

Upvotes: 4

Related Questions