Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

32 lines (24 sloc) 0.753 kb

dojo.on()

A simple Dojo plugin to enable an easier to read format for dojo.connect.


  // before
  var handle = dojo.connect(dojo.byId("someNode"), "click", function(evt) {
    evt.preventDefault();
    dojo.style(evt.currentTarget, "color", "red");
  });
  
  dojo.disconnect(handle);
  
  // with dojo.on()
  
  dojo.on("someNode", "click")
    .prevent()
    .then(function(evt){
      dojo.style(evt.currentTarget, "color", "red");
    })
    .disconnect();
    
  // with dojo.eat() and some friends
  // dojo.eat() is just like dojo.on().prevent()
  
  dojo.eat("someNode", "click")
      .then(function(evt) { 
        dojo.style(evt.currentTarget, "color", "red"); 
      })
      .disconnect();
               

Jump to Line
Something went wrong with that request. Please try again.