On Jul 18, 2007, at 10:08 PM, Ken Snyder wrote:
Object.assignGuid = function(object, prefix) {
if (prefix === undefined) prefix = '__guid';
if (!object.id) {
object.id = prefix + (arguments.callee.nextId++);
}
return object.id;
};
Object.assignGuid.nextId = 0;
I like your
Tobie Langel wrote:
...
I'm also concerned about naming the method adequately. Sam suggested
Element#denominate which looks nicer than (generate|assign)Id but
which I fear could be confused with setting the name attribute. The
only other option I came up with is Element#identify. Thoughts on
-1 for identify (we're not talking about the act of identifying something,
but generating a unique id)
-1 for making it an instance method on elements (see my last post for
reason)
+1 for getId
+1 for static method only (Element#getId)
Actually, this should really be so general as to not even be
Ryan Gahl wrote:
-1 for identify (we're not talking about the act of identifying
something, but generating a unique id)
-1 for same reason
-1 for making it an instance method on elements (see my last post for
reason)
-1 for same reason
+1 for getId
I actually like create better than get
Ken Snyder wrote:
The function seems more useful if it returns the id. I'd vote for the
name Element#getId().
Not getId() since that implies that the id already exists and this is simply
retrieving it. createId() would be more indicative of what it does.
But since all this does it create
Sorry for the triple posts, as you may have noticed, Google Groups
went really crazy today, and I really thought my messages just weren't
going through.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups
Prototype:
If this does make it to core, I would then also suggest allowing the
developer to specify the prefix of the ID (default to uniqueId).
Optionally, go so far as to track a separate incremented value per new
prefix, allowing the dev to essentially set up element groups. This would be
considered like
Ryan, that's a great idea. Although I don't anticipate using it
often, I can easily see how this would be indispensable in some
circumstances.
On Jul 17, 2007, at 6:32 AM, Ryan Gahl wrote:
If this does make it to core, I would then also suggest allowing
the developer to specify the
Pretty funny I actually ended up needing this very feature two days
later...
Anyway, working on a patch for it.
Jeff, Ryan: could you give me a use case for the scoped prefixes ? My
intial thought is to think they're overkill / too specific... but I
don't mind being prooved wrong.
I'm also
Jeff Watkins wrote:
...
Element.Methods.assignId = function(element) {
element= $(element);
if (!element.id)
element.id= uniqeId_ + (arguments.callee._nextUniqueId++);
return element.id;
}
Element.Methods.assignId._nextUniqueId=0;
...
+1 for such an addition. It is especially useful for
10 matches
Mail list logo