function unique(){
var dt = new Date();
return 'id_'+dt.getTime();
}
On Wed, Oct 29, 2008 at 11:20 AM, Vortexmind <[EMAIL PROTECTED]> wrote:
>
> Hi
> as I'm using mootools library to create new elements in my DOM tree,
> I've made a small function to return a new ID and ensure that it's not
> already defined in DOM tree. Here is it
>
> function __getUID(){
> var rand_letters =
>
> ['a','b','c','d','e','f','g','i','l','m','n','o','p','q','r','s','t','u','v','z'];
> var uid = null;
>
> while(true){
> uid = rand_letters.getRandom() + $random(0,20) +
> rand_letters.getRandom() + $random(0,20) + rand_letters.getRandom() +
> $random(0,20);
> if(!$defined($(uid)))break;
> }
> return uid;
> };
>
> well ... it's kinda paranoid and not so efficient but it works. Does
> anyone knows a better method to do this?
>
>
--
-----------------------------------------
Danillo César de O. Melo
www.sook.com.br