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.

Get Adobe Flash playerPlugin by wpburn.com wordpress themes