diff --git a/jquery.placeholder.js b/jquery.placeholder.js
index 03b04d1..7795f3b 100644
--- a/jquery.placeholder.js
+++ b/jquery.placeholder.js
@@ -1,5 +1,5 @@
/*!
- * HTML5 Placeholder jQuery Plugin v1.5
+ * HTML5 Placeholder jQuery Plugin v1.6
* @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
* @author Mathias Bynens
*/
@@ -24,7 +24,7 @@
return newAttrs;
}
- function onFocus() {
+ function clearPlaceholder() {
var $input = $(this);
if ($input.val() === $input.attr('placeholder') && $input.hasClass('placeholder')) {
if ($input.data('placeholder-password')) {
@@ -49,7 +49,7 @@
$replacement
.removeAttr('name')
.data('placeholder-password', true)
- .bind('focus.placeholder', onFocus);
+ .bind('focus.placeholder', clearPlaceholder);
$input
.data('placeholder-textinput', $replacement)
.before($replacement);
@@ -66,7 +66,10 @@
// Look for forms
$('form').bind('submit.placeholder', function() {
// Clear the placeholder values so they don’t get submitted
- $('.placeholder', this).val('');
+ var $inputs = $('.placeholder', this).each(clearPlaceholder);
+ setTimeout(function() {
+ $inputs.each(setPlaceholder);
+ }, 10);
});
});
@@ -77,7 +80,7 @@
$.fn.placeholder = function() {
return this.filter(':input[placeholder]')
- .bind('focus.placeholder', onFocus)
+ .bind('focus.placeholder', clearPlaceholder)
.bind('blur.placeholder' , setPlaceholder)
.trigger('blur.placeholder').end();
};
diff --git a/jquery.placeholder.min.js b/jquery.placeholder.min.js
index 1a3d6ad..cd02364 100644
--- a/jquery.placeholder.min.js
+++ b/jquery.placeholder.min.js
@@ -1,6 +1,6 @@
/*!
- * HTML5 Placeholder jQuery Plugin v1.5
+ * HTML5 Placeholder jQuery Plugin v1.6
* @link http://github.com/mathiasbynens/Placeholder-jQuery-Plugin
* @author Mathias Bynens
*/
-(function(d){if('placeholder' in document.createElement('input')){d.fn.placeholder=function(){return this};return}function a(f){var e={},g=/^jQuery\d+$/;d.each(f.attributes,function(j,h){if(!g.test(h.name)){e[h.name]=h.value}});return e}function b(){var e=d(this);if(e.val()===e.attr('placeholder')&&e.hasClass('placeholder')){if(e.data('placeholder-password')){e.hide().next().show().focus()}else{e.val('').removeClass('placeholder')}}}function c(f){var i,h=d(this);if(h.val()===''||h.val()===h.attr('placeholder')){if(h.is(':password')){if(!h.data('placeholder-textinput')){try{i=h.clone().attr({type:'text'})}catch(g){i=d('').attr(d.extend(a(h[0]),{type:'text'}))}i.removeAttr('name').data('placeholder-password',true).bind('focus.placeholder',b);h.data('placeholder-textinput',i).before(i)}h=h.hide().prev().show()}h.addClass('placeholder').val(h.attr('placeholder'))}else{h.removeClass('placeholder')}}d(function(){d('form').bind('submit.placeholder',function(){d('.placeholder',this).val('')})});d(window).bind('unload.placeholder',function(){d('.placeholder').val('')});d.fn.placeholder=function(){return this.filter(':input[placeholder]').bind('focus.placeholder',b).bind('blur.placeholder',c).trigger('blur.placeholder').end()}})(jQuery);
\ No newline at end of file
+(function(d){if('placeholder' in document.createElement('input')){d.fn.placeholder=function(){return this};return}function b(f){var e={},g=/^jQuery\d+$/;d.each(f.attributes,function(j,h){if(!g.test(h.name)){e[h.name]=h.value}});return e}function a(){var e=d(this);if(e.val()===e.attr('placeholder')&&e.hasClass('placeholder')){if(e.data('placeholder-password')){e.hide().next().show().focus()}else{e.val('').removeClass('placeholder')}}}function c(f){var i,h=d(this);if(h.val()===''||h.val()===h.attr('placeholder')){if(h.is(':password')){if(!h.data('placeholder-textinput')){try{i=h.clone().attr({type:'text'})}catch(g){i=d('').attr(d.extend(b(h[0]),{type:'text'}))}i.removeAttr('name').data('placeholder-password',true).bind('focus.placeholder',a);h.data('placeholder-textinput',i).before(i)}h=h.hide().prev().show()}h.addClass('placeholder').val(h.attr('placeholder'))}else{h.removeClass('placeholder')}}d(function(){d('form').bind('submit.placeholder',function(){var e=d('.placeholder',this).each(a);setTimeout(function(){e.each(c)},10)})});d(window).bind('unload.placeholder',function(){d('.placeholder').val('')});d.fn.placeholder=function(){return this.filter(':input[placeholder]').bind('focus.placeholder',a).bind('blur.placeholder',c).trigger('blur.placeholder').end()}})(jQuery);
\ No newline at end of file