Reputation: 4638
I'm a beginner to dojo toolkit. And I know that dojo.byId()
function is similar to JavaScript's document.getElementById()
but I don't understand what's the use of dom.byId()
.
Can someone explain me what are the differences between dom.byId() and dojo.byId()?
Upvotes: 2
Views: 1797
Reputation: 9900
The dojo syntax is pre AMD using the global dojo object. The dom syntax is when you load the dojo/dom module with the new AMD structure.
Edit
I suppose I should add an example.
// Pre-AMD (<1.7)
dojo.ready(function(){
var elm = dojo.byId('myElement'); // id="myElement"
})
// Dojo using AMD (1.7+)
require(['dojo/dom', 'dojo/domReady!'], function(dom){
var elm = dom.byId('myElement');
})
Dojo and AMD is tricky to get used to, at least it was for me.
More on AMD from RequireJS
Upvotes: 5