diff options
author | Rob Loach <robloach@gmail.com> | 2014-10-12 21:00:44 -0400 |
---|---|---|
committer | Rob Loach <robloach@gmail.com> | 2014-10-12 21:00:44 -0400 |
commit | 31d7ad9ddaf71321ca44ddc27880e5f0a2653f6c (patch) | |
tree | 5af67c895c9bc988120c1f86e3dce20d111471c7 | |
parent | 8488a8c2c1f2cedfd213b20ad46e1044e391c9d3 (diff) | |
download | jquery-once-31d7ad9ddaf71321ca44ddc27880e5f0a2653f6c.zip jquery-once-31d7ad9ddaf71321ca44ddc27880e5f0a2653f6c.tar.gz jquery-once-31d7ad9ddaf71321ca44ddc27880e5f0a2653f6c.tar.bz2 |
Update source
-rw-r--r-- | jquery.once.js | 5 | ||||
-rw-r--r-- | jquery.once.litcoffee | 7 |
2 files changed, 5 insertions, 7 deletions
diff --git a/jquery.once.js b/jquery.once.js index affaaed..593010e 100644 --- a/jquery.once.js +++ b/jquery.once.js @@ -13,10 +13,7 @@ uuid = 0; $.fn.once = function(id) { var name; - if (!id) { - id = ++uuid; - } - name = "jquery-once-" + id; + name = "jquery-once-" + (id || ++uuid); return this.filter(function() { return $(this).data(name) !== true; }).data(name, true); diff --git a/jquery.once.litcoffee b/jquery.once.litcoffee index 0f0f237..32c7e04 100644 --- a/jquery.once.litcoffee +++ b/jquery.once.litcoffee @@ -49,10 +49,11 @@ $('p').once('changecolor').css('color', 'green'); #### Source $.fn.once = (id) -> - # Generate a numeric id if the id doesn't exist. - id = ++uuid if !id + # Build the name for the data identifier. Generate a new unique id if + # the id parameter is not provided. + name = "jquery-once-" + (id or ++uuid) + # Filter the elements by which do not have the data yet. - name = "jquery-once-" + id @filter -> $(this).data(name) isnt true .data name, true |