Can Teleport appear at click on the reference?

Comments

digital_fox’s picture

I have inserted the link <a href="#" onclick="javascript: Drupal.Teleport.toggle(); return false;">help button</a>. Teleport appears and there and then disappears. In what a problem?

incidentist’s picture

Status: Active » Closed (works as designed)

The problem is that the toggle() function adds a click() handler to the document that checks to see if a click is outside the Teleport dialog. If it is outside the dialog, the dialog closes. Unfortunately, if you've activated the dialog using a click, that new handler gets run after the toggle() handler. The new handler, seeing that the click was outside the teleport window, closes the window that just opened.

A workaround is to remove the new handler at the end of the onclick:

<a onclick="javascript: Drupal.Teleport.toggle();  $(document).unbind('click', Drupal.Teleport.clickHandle);
return false;" href="#">help button</a>