Permalink
Browse files

updaing plugin with new option

  • Loading branch information...
1 parent 0cb4b9d commit 5d5f5e92fc3b8b31575e5235216b60bcba0d8aa8 Stephen Korecky committed Dec 14, 2010
Showing with 20 additions and 2 deletions.
  1. +15 −1 README.markdown
  2. +5 −1 addclear.js
View
@@ -1,10 +1,12 @@
**Author:** Stephen Korecky <br />
**Website:** http://stephenkorecky.com <br />
**Plugin Website:** http://github.com/skorecky/Add-Clear <br />
+----
+**Contributers:** <a href="https://github.com/scoman81">scoman81</a> <br />
## About
-**Version 1.0**
+**Version 1.1**
Add Clear is a jQuery plugin that adds a input clearing button on any input you apply it to. It clears the value, and returns focus to that field.
@@ -20,6 +22,13 @@ Add Clear is a jQuery plugin that adds a input clearing button on any input you
$(document).ready(function(){
$("input").addClear();
});
+
+ // Example onClear option usage
+ $("input").addClear({
+ onClear: function(){
+ alert("call back!");
+ }
+ });
</script>
### Available Options
@@ -55,6 +64,11 @@ Add Clear is a jQuery plugin that adds a input clearing button on any input you
<td>false</td>
<td>boolean</td>
</tr>
+ <tr>
+ <td>onClear</td>
+ <td>null</td>
+ <td>function</td>
+ </tr>
</table>
#### Using Options
View
@@ -10,7 +10,8 @@
top: 0,
right: 4,
returnFocus: true,
- showOnLoad: false
+ showOnLoad: false,
+ onClear: null
}, options);
$(this).wrap("<span style='position:relative;' class='add-clear-span'>");
@@ -45,6 +46,9 @@
if(options.returnFocus === true){
$(this).siblings("input").focus();
}
+ if (options.onClear){
+ options.onClear($(this).siblings("input"));
+ }
return false;
});
return this;

0 comments on commit 5d5f5e9

Please sign in to comment.