Opened 12 years ago

Closed 12 years ago

Last modified 8 years ago

#4870 closed defect (worksforme)

dijit.form.FilteringSelect, setValue & onChange

Reported by: guest Owned by: Douglas Hays
Priority: high Milestone: 1.1
Component: Dijit - Form Version: 1.0
Keywords: FilteringSelect setValue onChange Cc: cdupetit@…
Blocked By: Blocking:

Description

Hello, I use the setValue function to select a default value in the FilteringSelect? dijit, but this function seems to not call the onChange function. Is this the correct behaviour ? Thx in advance. Kilroy

Attachments (2)

test_FilteringSelect.html (1.1 KB) - added by Douglas Hays 12 years ago.
dijit/tests/form/test_FilteringSelect.html
states.json (3.8 KB) - added by Douglas Hays 12 years ago.
dijit/tests/_data/states.json

Download all attachments as: .zip

Change History (10)

comment:1 Changed 12 years ago by Adam Peller

Owner: set to Douglas Hays

comment:2 Changed 12 years ago by Douglas Hays

Resolution: worksforme
Status: newclosed

This seems to work for me. Can you append a testcase? The nightly build has an example of a setDisplayedValue() that triggers onChange. http://archive.dojotoolkit.org/nightly/dojotoolkit/dijit/tests/form/test_FilteringSelect.html The first select box has a button to set the value to Kentucky and you can see the input box to the right change to KY via onChange.
You can modify this test to call
setValue('KY')
instead of
setDisplayedValue('Kentucky')
to verify that this works as well.

comment:3 Changed 12 years ago by guest

Resolution: worksforme
Status: closedreopened

The difference with the example is that I create my dijit programaticaly.

var w = dojo.byId('actionsAvalon');
if (w)
{
	var dfltValue = w.value;
	w = new dijit.form.FilteringSelect
	(
		{
		    name          : w.name
		  , type          : w.type
		  , disabled      : w.disabled
		  , autocomplete  : true
		  , required      : true
		  , store         : new dojo.data.ItemFileReadStore({ url: '/avalon/getActions' })
		  , onChange      : function(action) {_this.onChangeAction(action); }
		  , searchAttr    : 'label'
		  , invalidMessage: _this._strings['invalid_action']
		  , promptMessage : _this._strings['missing_action']
		}
		, w
	);
	w.setValue(dfltValue);
	/* [BUG] Ticket #4870: setValue don't call onChange */
	_this.onChangeAction(dfltValue);
}

Even If i set the value in the constructor.

Kilroy

comment:4 Changed 12 years ago by bill

Maybe there's a race condition if you call setValue() before the store has loaded the data? Try attaching the setValue() call to a button, or running after a delay, to see if that works.

Also, you can (and should) attach testcases using the "attach file" button.

BTW, you can replace {{ {function(action) {_this.onChangeAction(action); } }}} with dojo.hitch(_this, "_onChangeAction") . It's just a little shorter to type.

comment:5 Changed 12 years ago by bill

Milestone: 1.01.1

comment:6 Changed 12 years ago by guest

I've changed :

w.setValue(dfltValue);
/* [BUG] Ticket #4870: setValue n'appelle pas onChange */
_this.onChangeAction(dfltValue);

with :

setTimeout
(
    function(){dijit.byId('actionsAvalon').setValue(dfltValue);}
  , 15000
);

but setValue don't call onChange.

Kilroy

Changed 12 years ago by Douglas Hays

Attachment: test_FilteringSelect.html added

dijit/tests/form/test_FilteringSelect.html

Changed 12 years ago by Douglas Hays

Attachment: states.json added

dijit/tests/_data/states.json

comment:7 Changed 12 years ago by Douglas Hays

Resolution: worksforme
Status: reopenedclosed

I attached a programmatic example that works perfectly. Please try to recreate, starting with this example and tweak until it fails. Also, make sure you are using the latest trunk. I tested with [11354] with FF2 and IE6 on WinXP.

comment:8 Changed 8 years ago by bill

Component: DijitDijit - Form
Note: See TracTickets for help on using tickets.