[Dojo-interest] object reference from dojo.io.bind OR who am I

Nick ngeron at corenap.com
Wed Sep 6 15:27:06 MDT 2006

Hi all,

I'm just getting my feet wet with dojo, so perhaps the answer is 
obvious.  Please bonk me over the head if so.  I'm seeing an issue of 
scope or reference in a call back method set as the handler for a 

Basically I need a simple select box (not combo) that is populated with 
  server side content but can be validated/required much like a 
ValidateTextBox.  I've done this before with hand wrought code, but 
wanted a more configurable/reusable form in a widget.

The specific problem occurs when my callback function is called from 
dojo.io.bind.  Below is a stripped down example of the pertinent methods:

initializer: function() {
	alert(this); // alert # 1

populateSelect: function() {
   		url: "getList.php?listType="+this.listType,
     		handler: this.populateSelectCallBack

populateSelectCallBack: function(type, data, evt) {
	alert(data); // alert # 2
	alert(this); // alert # 3
	//this.generateOptionElements(stuff); // I wish I could execute

The alerts were added to diagnose and pointed me in the right direction.

1) The first alert shows the expected [Widget ValidateSelectBox NO ID], 
as does this same alert inserted almost anywhere else in the widget.

2) The second alert shows the expected dummy string returned from my php 
script.  This tells me dojo.io.bind is doing it's job up to that point.

3) The third alert shows an identity crisis - [object Object]. Thus all 
further calls fail. This breaks things since that function then called 
another to parse the returned data and populate option elements.

4) If I call populateSelectCallBack explicitly somewhere else within the 
widget (say, in the initialzer) all is well.

I'm fairly confident from #4 that the error is related to interactions 
with my widget and external (dojo.io) code, but I'm at a loss.  Any help 
would be much appreciated.  Thanks!

Nick Geron - Core NAP Jack o' all Trades
ngeron at corenap.com

More information about the Dojo-interest mailing list