Closed stukalin closed 6 years ago
"slightly"
just a couple orders of magnitude. lol
The current discussion seems to be at https://github.com/mathiasbynens/jquery-placeholder/issues/244
There was a discussion on this section of code at https://github.com/mathiasbynens/jquery-placeholder/commit/0db4369fdf2cefa87d81e55ef6dc586ba4eed6bb#comments where another person - back in 2012! - said that this same setTimeout was causing intermittent submission of the placeholder text to the server and that deleting it fixed it.
So basically there is a race condition in the submission and the setPlaceholder()
firing. It seems like there should be a better way to work around this than a setTimeout (and maybe it could be shorter), but something is better than nothing.
:+1:
customClass: 'placeholder',
hiddenOnfocus:true//if hide placeholder value when on focus for mordern browser
};
if (isInputSupported && isTextareaSupported) {
placeholder = $.fn.placeholder = function (option) {
settings = $.extend({},defaults,option);
if(settings.hiddenOnfocus){
return this.filter('[placeholder]')
.bind({
'focus.placeholder': clearPlaceholderInMordernBrowser,
'blur.placeholder': setPlaceholderInMordernBrowser
})
.data('placeholder-enabled', true)
.trigger('blur.placeholder');
}else{
return this;
}
};
placeholder.input = true;
placeholder.textarea = true;
var clearPlaceholderInMordernBrowser = function(event){
var input = this;
var $input = $(this);
if (input.value === "" && $input.hasClass(settings.customClass)) {
$input.attr('placeholder',"");
$input.removeClass(settings.customClass);
input == safeActiveElement() && input.select();
}
};
var setPlaceholderInMordernBrowser = function(event){
var input = this;
var $input = $(this);
if($input.attr('placeholder') != ""){
$input.data('placeholder-data', $input.attr('placeholder'));
}
if(input.value === ""){
$input.addClass(settings.customClass);
$input.attr('placeholder',$input.data('placeholder-data'));
}else{
$input.removeClass(settings.customClass);
}
};
}
I had an issue when placeholder values have been submitted. I increased the timeout slightly and it helped.