diff --git a/jquery.placeholder.js b/jquery.placeholder.js index 209d200..8fea7f0 100644 --- a/jquery.placeholder.js +++ b/jquery.placeholder.js @@ -26,6 +26,7 @@ 'focus.placeholder': clearPlaceholder, 'blur.placeholder': setPlaceholder }) + .data('jquery-placeholder-enabled', true) .trigger('blur.placeholder').end(); }; @@ -34,17 +35,23 @@ hooks = { 'get': function(element) { - var $element = $(element); - return $element.hasClass('placeholder') ? '' : element.value; + var $element = $(element), + isPlaceholderEnabled = $element.data('jquery-placeholder-enabled'); + return (isPlaceholderEnabled && $element.hasClass('placeholder')) ? '' : element.value; }, 'set': function(element, value) { - var $element = $(element); - if (value == '') { - element.value = value; - // We can’t use `triggerHandler` here because of dummy text/password inputs :( - setPlaceholder.call(element); - } else if ($element.hasClass('placeholder')) { - clearPlaceholder.call(element, true, value) || (element.value = value); + var $element = $(element) + isPlaceholderEnabled = $element.data('jquery-placeholder-enabled'); + if (isPlaceholderEnabled) { + if (value == '') { + element.value = value; + // We can’t use `triggerHandler` here because of dummy text/password inputs :( + setPlaceholder.call(element); + } else if ($element.hasClass('placeholder')) { + clearPlaceholder.call(element, true, value) || (element.value = value); + } else { + element.value = value; + } } else { element.value = value; }