From 2cc2d7177bea1922b49eabb4c6e111f3ce8e1c86 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Wed, 31 Jul 2013 13:04:14 -0700 Subject: [PATCH] added name method --- History.md | 4 ++++ Readme.md | 9 ++++++--- component.json | 2 +- index.js | 13 +++++++++++++ 4 files changed, 24 insertions(+), 4 deletions(-) diff --git a/History.md b/History.md index aeb6249..ec54402 100644 --- a/History.md +++ b/History.md @@ -1,3 +1,7 @@ +0.0.2 - July 31, 2013 +--------------------- +* added `name` method + 0.0.1 - July 10, 2013 --------------------- :sparkles: \ No newline at end of file diff --git a/Readme.md b/Readme.md index 98bccbf..e51776c 100644 --- a/Readme.md +++ b/Readme.md @@ -39,13 +39,16 @@ toggle.value(); // false ### Toggle(value, el) Create a new toggle with an optional starting `value` and optional `el` to use instead of creating one. -### .el +### #el The toggle's DOM element. -### .value(val) +### #value(val) Get or set the value of the toggle. -### .toggle() +### #name(name) + Set the toggle's internal checkbox's name, so forms can be submitted properly. + +### #toggle() Toggle the value of the toggle. ### .label(on, off) diff --git a/component.json b/component.json index c2f06a6..465dd7f 100644 --- a/component.json +++ b/component.json @@ -2,7 +2,7 @@ "name": "toggle", "repo": "segmentio/toggle", "license": "MIT", - "version": "0.0.1", + "version": "0.0.2", "description": "A toggle UI element.", "keywords": ["toggle", "ui", "checkbox"], "dependencies": { diff --git a/index.js b/index.js index 5c83d85..ca24c26 100644 --- a/index.js +++ b/index.js @@ -53,6 +53,19 @@ Toggle.prototype.value = function (val) { }; +/** + * Set the toggle's name, on the checkbox. That way forms that get submitted + * will get the proper value. + * + * @param {String} name + * @return {Toggle} + */ + +Toggle.prototype.name = function (name) { + this.checkbox.name = name; +}; + + /** * Toggle the toggle :) *