_.uniqueId is unique per page load, switch back to hex style unique id

This commit is contained in:
egghead 2013-02-28 05:40:32 +00:00
parent 1352a1b827
commit 0994cb003a

View file

@ -9,9 +9,13 @@ var util = (function() {
// milliseconds. Tries to minimize latency.
return _.debounce(f, period)
},
// Unique IDs
uniqueId: _.uniqueId
}
uniqueId: function(length) {
// Unique-ish IDs as a length sized string of hex
var id = '', hex = '0123456789abcdef';
_(length || 40).times(function() { id += hex[_.random(15)]; });
return id;
}
};
})();
$(function() {