storm_buster
storm_buster

Reputation: 7568

What the difference between dojo.byId and dijit.byId?

Each time am trying the get the value of an element in my page, I have an error as is undefined: I have tried dijit.byId('myid').innerHTML('loading...');

I get an error but when i do the same using jquery, it works $­('#myid').html('loading ...')

And what is the equivalent of this $('#myid').html() in dojo? Thanks for any advise

Upvotes: 8

Views: 9880

Answers (2)

Rajan
Rajan

Reputation: 111

dijit.byId("my_id") ----> returns the widget associated with the domNode.
dojo.byId("my_id") -----> returns the domNode itself.

To access the domNode using dijit:

dijit.byId("my_id").domNode.innerHTML

Upvotes: 3

Gabi Purcaru
Gabi Purcaru

Reputation: 31524

dijit.byId returns a dijit object by some id.

dojo.byId is the equivalent of $(). To get/set it's HTML, use

dojo.byId("my_id").innerHTML
dojo.byId("my_id").innerHTML = some_text`

Note that dojo.byId is just a wrapper around document.getElementById, so you can use all the basic functions.

Upvotes: 10

Related Questions