I'm trying to use digit/registry to get the object for a digit so I can read/change its proprerties. But for some reason I get a JavaScript error that no "byId" method exists for the registry object in the (trimmed-down) code below:
define(["dojo/dom-style", "dijit/registry", [...] ],
function(domStyle, registry, [...])
{
var self =
{
moveSplitter: function(datasetsLength)
{
var myBC = registry.byId("studiesBorderContainer");
},
}
}
I seem to be able to duplicate this problem in JSFiddle:
http://jsfiddle.net/rUNNr/2/
Yet it works on the Dojo documentation page (see the example at the very bottom of the page... compare first line of output when you click Run with that on the JSFiddle.)
What am I missing? (Note: it's also possible I didn't set up the JSFiddle correctly for a dojo example.)
It appears (at least in the Fiddle you linked to), that you are never actually creating the dijit by calling parser.parse().
I added the call to parser.parse as the first line in your ready callback, and got back a valid dijit Id from registry.byId().
The registry.byId() documentation provides insight into this:
... it only works on parsed dijits either declared in markup with a data-dojo-type attribute or programmatically. The same id attribute is used as a parameter, but what is returned in this case is an object that was created by the dojo widget system when the markup is parsed and transformed into a dijit.
So in your example, this behavior makes sense:
Adding this line to your Fiddle made the example work as intended.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With