Skip to content

Commit

Permalink
We don’t want to stop the plugin after event.preventDefault() in a su…
Browse files Browse the repository at this point in the history
…bmit handler. Fixes mathiasbynens#5.
  • Loading branch information
mathiasbynens committed Oct 16, 2010
1 parent 2f4dece commit 0fefabf
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 7 deletions.
13 changes: 8 additions & 5 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
@@ -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 <http://mathiasbynens.be/>
*/
Expand All @@ -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')) {
Expand All @@ -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);
Expand All @@ -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);
});
});

Expand All @@ -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();
};
Expand Down
4 changes: 2 additions & 2 deletions jquery.placeholder.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0fefabf

Please sign in to comment.