Skip to content

Commit

Permalink
Make submit handler work for dynamically inserted forms
Browse files Browse the repository at this point in the history
Fixes mathiasbynens#41. This plugin now requires jQuery 1.4.2 (since we’re using `jQuery#delegate`).
  • Loading branch information
mathiasbynens committed Dec 24, 2011
1 parent e8a1b12 commit 06d8e67
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 4 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ input, textarea { color: #000; }

## Notes

* Requires jQuery 1.4.2+.
* Works in all A-grade browsers, including IE6.
* Automatically checks if the browser natively supports the HTML5 `placeholder` attribute for `input` and `textarea` elements. If this is the case, the plugin won’t do anything. If `@placeholder` is only supported for `input` elements, the plugin will leave those alone and apply to `textarea`s exclusively. (This is the case for Safari 4, Opera 11.00, and possibly other browsers.)
* Caches the results of its two feature tests in `jQuery.fn.placeholder.input` and `jQuery.fn.placeholder.textarea`. For example, if `@placeholder` is natively supported for `input` elements, `jQuery.fn.placeholder.input` will be `true`. After loading the plugin, you can re-use these properties in your own code.
Expand Down
4 changes: 2 additions & 2 deletions jquery.placeholder.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
/*! http://mths.be/placeholder v1.8.6 by @mathias */
/*! http://mths.be/placeholder v1.8.7 by @mathias */
;(function(window, document, $) {

var isInputSupported = 'placeholder' in document.createElement('input'),
Expand Down Expand Up @@ -30,7 +30,7 @@

$(function() {
// Look for forms
$('form').bind('submit.placeholder', function() {
$(document).delegate('form', 'submit.placeholder', function() {
// Clear the placeholder values so they don’t get submitted
var $inputs = $('.placeholder', this).each(clearPlaceholder);
setTimeout(function() {
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 06d8e67

Please sign in to comment.