Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I hide a dijit/form/button?

Tags:

dojo

I think it is a common sense that providing a simple way to hide/show and enable/disable a button, but I cannot find any document that describe dojo has done such thing. Any way, I hope it is my fault that I have missed out something while googling, thanks!

The following coding is what I have tried but they just make the button's text invisible:

dojo.style(btnInsert, {'visibility':'hidden'});
dojo.style(btnInsert, {'display':'none'});

UPDATE Question:

To oborden2:

I have tried your code, the result is same as the above code, here is the captured screen:

enter image description here

To MiBrock:

I have also tried your code and also get the result that same as the above code: enter image description here

like image 976
Steve Lam Avatar asked Aug 07 '13 07:08

Steve Lam


1 Answers

Form widgets in Dijit are special. For all normal Dijit widgets, the domNode (outermost node) of the widget receives the id property. However, with form widgets, the focusNode (which corresponds to the <input> element) receives the ID instead, so that things like <label for="foo"> work properly. In this case, the outermost node has no ID, and you’re actually just hiding the inner HTML input element.

If you already have reference to the widget:

require([ 'dojo/dom-style' ], function (domStyle) {
    domStyle.set(widget.domNode, 'display', 'none');
});

If you only have a reference to the ID of the widget/original DOM node:

require([ 'dojo/dom-style', 'dijit/registry' ], function (domStyle, registry) {
    domStyle.set(registry.byId(nodeId).domNode, 'display', 'none');
});
like image 125
C Snover Avatar answered Sep 22 '22 06:09

C Snover