3
Aug/09
3

Dijit Tooltips

Why such poor documentation?

I find it very hard to understand why Zend would choose such a poorly documented Javascript library to include with their framework. I understand Dojo itself has some undergone some serious changes with even minor releases (I am using version 1.3) which is very, very frustrating for developers. I have not had any problems finding documentation for Prototype or jQuery. Why is there such a lack of documentation for such a high profile library? I even attended the Rational Developers Conference and IBM was pushing the dojo framework. It makes me want to bang my head against the wall. Everything I could find is outdated.

Now that my rant is over, it does look like dojotoolkit.org is being updated with current data. Perhaps, if Zend will continue to ship their framework with dojo, they can send some money their way to help resolve this issue. Otherwise, we may see a lot of people going back to Prototype, jQuery, or YUI.

To the subject at hand

Such a simple task, yet all documentation I could find is out of date. Here is how to create a tooltip with dojo and dijit in a Zend page template. In this case I added a tooltip to the search form.

myPage.phtml

<?php 
   echo $this->headLink()->appendStylesheet('/styles/forms.css');
   echo $this->dojo()->enable()->setLocalPath('/scripts/Dojo/dojo/dojo.js')
          ->addStyleSheetModule('dijit.themes.tundra')
          ->setDjConfigOption('parseOnLoad', true)
          ->requireModule('dijit.Tooltip');
?>
<div id="search_form">
	<form id="search" onsubmit="return false">
		Search: <input type="text" id="search_box" onkeypress="search(event)" />
		<div dojoType="dijit.Tooltip" connectId="search_box" label="<div style='text-align:left'><b>To search for $ amount:</b><br /> Enter '<' or '>' and amount. <br /><br /><b>To search a state</b><br /> Enter the state name.<br /><br /><b>Everything else</b><br />Just enter the text to search for.</div>"></div>		
	</form>
</div>

What it does

When the user hovers over the search field a tooltip is shown, giving the user suggestions on how to use the search. Simple enough, right? Just require the correct modules, use “connectId” to assign the tooltip to the correct element, and use the label attribute to set the text of your tooltip. Was that so hard? Perhaps dojotoolkit.org should go to a wiki format so we developers can update it as we figure out how to use it.

Comments (3) Trackbacks (0)
  1. Daniel
    8:15 pm on December 13th, 2009

    Can you give me your controller code for a Dojo tooltip. I’ve spent two days looking for docs on how to do this.

    Thanks
    -Daniel

  2. Jason Houle
    10:32 am on December 15th, 2009

    Daniel, can you be more specific? What is it you are trying to do? You should not need any controller code to add a tooltip to a page. It should all be done in the markup.

    • Daniel
      9:17 pm on March 16th, 2010

      What I was trying to do is to create a tooltip / floating list from remote data. I have a list of stores. In that list, I wanted a have an area, that would allow a user to view ideas from that store. The list would be quit large per store, so I didn’t want the use to download 2MB or more of html. I wanted the list to get create from a url when the user hover over a link.

      For now, I did the it “fat” why, the user has to download the full html document.

      Thanks
      -Daniel

Leave a comment

No trackbacks yet.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes