Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

like image 415
storm_buster Avatar asked Nov 11 '10 20:11

storm_buster


People also ask

What is Dojo and Dijit?

dijit is the package that contains the widget library for Dojo Toolkit. It requires the core of the Dojo Toolkit and provides a framework for building additional widgets as well as a full set of rich user interface widgets including form, layout and data-aware items.

What is a Dijit?

Dijit is a widget system layered on top of Dojo. If you are new to the whole Dojo experience, Dijit is a good place to start. You can build amazing Web 2.0 GUI's using very little, or no, JavaScript (though having an understanding of JavaScript will take you a long way, as will a good understanding of HTML and CSS).

What is widget in Dojo?

The Dojo Toolkit ships with the Dijit framework, which is a set of graphical controls called widgets. We can build graphical user interfaces with these widgets.


2 Answers

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.

like image 74
Gabi Purcaru Avatar answered Oct 16 '22 19:10

Gabi Purcaru


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
like image 3
Rajan Avatar answered Oct 16 '22 19:10

Rajan