Showing posts with label Dojo. Show all posts
Showing posts with label Dojo. Show all posts

Tuesday, June 15, 2010

Dojo filteringselect popup out of position on window resize

There is an issue(or enhancement request if you want to be specific) with the Dojo dijit.form.FilteringSelect widget where if you resize your browser window while the popup containing the dropdown options is open the popup retains it's original positioning relative to the browser window edge not it's parent widget e.g. the FilteringSelect text box.

This is documented fairly well at Ticket #5777 popups: close when window resized.

In the case of filtering select I feel it is a valid workaround to close the popup on window resize.

My workaround is here, although I am sure there may be more elegant ways. This assumes some familiarity with dojo and the FilteringSelect widget.

Start with the widget itself, assume you have necessary infrastructure for this FilteringSelect i.e. data store, dojo.requires, etc...
<input dojoType="dijit.form.FilteringSelect"
searchAttr="name" store="principalRisk1DataStore" class="medium" id="principalrisk1" name="principalrisk1" />


In order to close the popup containing the drop down selections for this FilteringSelect I need an onResize method


function onWindowResize()
{
//get the popup created when you click the widget, by default this seems to be the id of your input + _popup
var principalRisk1 = dijit.byId('principalrisk1_popup');
//useful for firebug to see what you get
console.debug(principalRisk1);
//this method closes the popup node you retrieved
dijit.popup.close(principalRisk1);
}


Now, lastly add this to the body tag's handler for onresize

<body class="tundra" onresize="onWindowResize()">

Saturday, May 15, 2010

Enter the Dojo

I was struggling with a project at work last week involving Dojo, and elements of AJAX, JSON.

One downside, the Dojo documentation is all over the place, a lot of it is incomplete and when you google search you often see out of date pages or broken links come up first.

My project was cool in a way and I can go into what it involved. But first to give credit where credit is due, I found this really helpful tutorial to add checkbox inputs to a Dojo/Dijit tree (yes it is much harder than one would think)

http://www.thejekels.com/dojo/Dijit_Tree_Chkbox.html

Examples were easy to follow and worked (note that the first steps in the tutorial don't actually work in Dojo 1.4, but he helpfully points that out the workarounds near the end).