diff options
author | Rob Loach <robloach@gmail.com> | 2014-12-15 09:56:28 -0500 |
---|---|---|
committer | Rob Loach <robloach@gmail.com> | 2014-12-15 09:56:28 -0500 |
commit | 6a2ab3c7f9d58f2d47398ac29af06dec14c4612e (patch) | |
tree | 54a03afe7b3e83ec3489dd719a9b710896656e4c /jquery.once.js | |
parent | 03027a958db2e5af6c49156f97b8879cdc612a65 (diff) | |
parent | 779c426bf61ec43488a91bac78faf3971333e4cf (diff) | |
download | jquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.zip jquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.tar.gz jquery-once-6a2ab3c7f9d58f2d47398ac29af06dec14c4612e.tar.bz2 |
Merge pull request #23 from theodoreb/default-parameter
Add a default value for once name and check once parameter is a string
Diffstat (limited to 'jquery.once.js')
-rw-r--r-- | jquery.once.js | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/jquery.once.js b/jquery.once.js index 4664218..87741f9 100644 --- a/jquery.once.js +++ b/jquery.once.js @@ -53,8 +53,9 @@ * @public */ $.fn.once = function (id) { - if (!id) { - throw new Error("An ID is required when calling jQuery.once()"); + id = id || "once"; + if (typeof id !== "string") { + throw new Error("jQuery.once() parameter MUST be a string"); } // Build the name for the data identifier. Generate a new unique id if the // id parameter is not provided. |