Guyz, I’ve a weird situation: I need to pre-compile input field when visitor opens a pop-up window by clicking on the button.
See here: http://www.ageditalia.it/ in the header click on a little banner that says email and password. Pop-up will jump out. I need these password and email written on the banner to be inserted with jquery automatically.
I tried this:
$("a:.loginonthefly-open").click(function (event) {
$("#auth_username").blur(function()
{
if ($(this).val() == "")
{
$(this).val("haha");
}
});
$("#auth_username").blur();
});
but field input gets cleared, I see my haha text for few seconds and than it disappears.
I don’t understand what is going on,
Any help appreciated!
EDIT:
So far I got this, it works only on the second click when html is inserted in dom. Doesnt work on first click on fresh page load!
$("a:.loginonthefly-open").click(function (event) {
if($("#auth_username").val() == "") {
$("#auth_username").delay(200).queue(function(){
$("#auth_username").val("TEST");
});
}
});
How do I make it work on first load?
Obviously I need a better handler than click. any thoughts?
Why are you hooking the code to the blur event? Try just doing it in the click function: