I ran into a problem the other day when trying to set the visibility style attribute on a Dojo button. I assumed that setting styles on a Dijit was similar to setting the style on any other DOM element:
dojo.style(node, style, value) |
But setting styles on a Dijit does not work they one would expect. My original code:
var btn = dijit.byId('register_btn'); dojo.style(btn, {visibility:'visible'}); |
This did not work because ‘btn‘ is not a DOM node. After an hour or so of trying different ways to get the code to work, I finally tried:
var btn = dijit.byId('register_btn').domNode; dojo.style(btn, {visibility:'visible'}); |
It worked. And it makes sense. I can further simplify it with:
dojo.style(dijit.byId('register_btn').domNode, {visibility:'visible'}); |
While I have accessed widgets (Dijits) using the domNode in the past, I just didn’t think that I would have to when using dojo.style. But it works, so I can move on.