Opened 12 years ago
Closed 11 years ago
#8882 closed enhancement (wontfix)
Suggest bringing back generateUniqueId
Reported by: | dante | Owned by: | anonymous |
---|---|---|---|
Priority: | high | Milestone: | |
Component: | Core | Version: | 1.3.0b3 |
Keywords: | Cc: | ||
Blocked By: | Blocking: |
Description
There are a couple of places in our codebase where we're doing some manual lookup for generating a unique ID (either DOM, or Dijit Widget ID, or function_exists() style checks [eg: jsonp callback generation]
I added a small function to plugd called dojo.unique
which seems to cover all these use cases fine. Submitting this ticket to formally trac the request. (wontfix is fine, just looking for feedback). The only real limitation of my implementation is the ID counter is global, so dijit.byId checks and dojo.byId checks will increment together:
(function(d){ var counter = 0, globalId = ""; d.unique(testFn, base){ do{ globalId = (base || "djid_") + (counter++); } while(testFn(globalId)) return globalId; } })(dojo);
and in this example, to get a uniuqe dom ID for your use:
var id = dojo.unique(dojo.byId);
or a jsonp callback:
var cb = dojo.unique(function(item){ return item in dojo.io.script; }); dojo.io.script[cb] = function(){ ... }
The testFn is required, and may infinite loop if omitted. The function could handle this case, but is currently designed for size.
Change History (2)
comment:1 Changed 12 years ago by
Milestone: | tbd → 1.4 |
---|
comment:2 Changed 11 years ago by
Milestone: | 1.4 |
---|---|
Resolution: | → wontfix |
Status: | new → closed |
1.3rc1 has been release; bumping remaining tickets to 1.4 (except for documentation/testing tickets)