> the toggle function toggle the display not any action.

There are two .toggle() signatures, this is the event one:
http://docs.jquery.com/Events/toggle

>        $(this).didSomeThing = false;

Each time you use $(this) you are creating a new jQuery object out of
the current element. Because of that, the didSomeThing property will
not be the same across the different $(this) instances. You could,
however, set and read this.didSomeThing directly on the DOM element.

Also, the dblclick event bubbles, so if you double-click something
inside the li it will run the li handler code, and any double-click
handlers in outer elements will also run. That may or may not be what
you want. Most of the time you'll want to prevent the default action
and stop bubbling by returning false.

$("li").dblclick(function(e) {
  if ( this._toggle ) {
    // do something here
   this._toggle = false;
  } else {
    // do something else here
   this._toggle = true;
  }
  e.preventDefault();
  return false;
});

Reply via email to