Dojo show () and hide () porting from jquery ()

I just port a bunch of code from jQuery to DOJO (1.8). I stumbled on showing / hiding DOM elements (let it be layers or something else).

Let's say we have a layer that we want to show or hide, without animation. Imagine that a Button Button that changes on an event, I don’t necessarily want to constantly add graphic effects.

<div id="myLayer">hide me</div> 

In jQuery, I would do:

 $("#myLayer").show(); // to show $("#myLayer").hide(); // to hide 

which I find very beautiful and slim. Now porting to DOJO, I found that I need to do the following:

 require(["dojo/fx/Toggler"], function(Toggler) { // Create a new Toggler with default options var toggler = new Toggler({ node: "myLayer", hideDuration: 0, showDuration: 0 }); // Hide the node toggler.hide(); // Show the node toggler.show(); }); 

These are 8 lines of code and 2 lines of code. Am I missing something? Is there a faster way to make simple conjugation?

Thanks a lot Tobi

+4
source share
1 answer
 require(["dojo/query", "dojo/NodeList-dom", "dojo/domReady!"], function(query){ query("#myLayer").style("display", "none"); }); 
+6
source

All Articles