8

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

Gabi Purcaru
  • 30,940
  • 9
  • 79
  • 95
storm_buster
  • 7,362
  • 18
  • 53
  • 75

2 Answers2

10

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.

Gabi Purcaru
  • 30,940
  • 9
  • 79
  • 95
  • 2
    DojoCampus has a detailed article on *jsId, dijit.byId() and dojo.byId()*: http://dojocampus.org/content/2008/05/06/jsid-dijitbyid-and-dojobyid/ – viam0Zah Nov 11 '10 at 21:28
  • 2
    Should qualify that `dojo.byId` is the equivalent of `$()` presumably in Prototype; jQuery's `$()` is more along the lines of `dojo.query`. I've written about some common points of confusion between dojo base and Dijit as well, maybe it'll help: http://kennethfranqueiro.com/2010/06/of-dijits-and-dom-nodes/ – Ken Franqueiro Nov 12 '10 at 04:35
3
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
Rajan
  • 111
  • 6