diff options
author | neilmonroe <neil.monroe@gmail.com> | 2009-03-20 14:28:25 -0700 |
---|---|---|
committer | neilmonroe <neil.monroe@gmail.com> | 2009-03-20 14:28:25 -0700 |
commit | 00e7013ba49f652f6cfaeb10a437f5220dbfefc6 (patch) | |
tree | 874e3850979a19c7a26d71fe5dcc10cc4302fefc | |
parent | ba47f76af8e44138311e2d9e8742957e885464ca (diff) | |
download | jquery-countable-00e7013ba49f652f6cfaeb10a437f5220dbfefc6.zip jquery-countable-00e7013ba49f652f6cfaeb10a437f5220dbfefc6.tar.gz jquery-countable-00e7013ba49f652f6cfaeb10a437f5220dbfefc6.tar.bz2 |
Added example markup.
-rw-r--r-- | README.markdown | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/README.markdown b/README.markdown index c3b98a3..4f194ed 100644 --- a/README.markdown +++ b/README.markdown @@ -20,6 +20,30 @@ The countable plugin has 11 settings: * `negativeCopy` - The copy to use when the character count is over the max. Use `{n}` to denote where the number should go. Default is "You are {n} characters over.". * `fadeDuration` - The duration of the fade animations. Default is 'normal'. +## Examples + +Add counter to all textarea objects on the page using defaults: + $("textarea").countable(); + +Add counters to a specific set of text fields, before each element: + $("#myTextBox, textarea.info").countable({ appendMethod: "insertBefore" }); + +Add counter to a specific textarea, but display in a given container element (with other advanced options): + $("#comments").each(function() { + $(this).countable({ + threshold: .75, + appendMethod: "appendTo", + target: $(this).parent().find("label small"), + startOpacity: 1, + maxLength: $(this).metadata().maxLength, + positiveCopy: " ({n} characters left)", + negativeCopy: " ({n} characters over the limit)", + fadeDuration: 0 + }) + }); + +Note: In the last example, the code is wrapped in an 'each' function call to get 'this' to point to the text element. Also, 'maxLength' is being pulled from contextual information using the metadata jQuery plugin (http://plugins.jquery.com/project/metadata). + ## License The expandable plugin is dual licensed *(just like jQuery)* under the [MIT](http://www.opensource.org/licenses/mit-license.php) and [GPL](http://www.opensource.org/licenses/gpl-license.php) licenses. |