Opened 9 years ago

Closed 9 years ago

Last modified 8 years ago

#11238 closed defect (fixed)

Select.onFetch does not provide this.

Reported by: sayuri Owned by: bill
Priority: high Milestone: 1.6
Component: Dijit - Form Version: 1.5.0b2
Keywords: Cc:
Blocked By: Blocking:

Description

In setStore() at dijit.form._FormSelectWidget,

if(fetchArgs.onFetch){
  items = fetchArgs.onFetch(items);
}

onFetch() are called normally. At onFetch(), I try to manipulate items args, but it does not provide the store or this select widget.

This should be

items = fetchArgs.onFetch.call(this, items);

I think.

Change History (5)

comment:1 Changed 9 years ago by bill

Milestone: tbd1.6

Seems simple enough. The declaration for onFetch should also be changed to a function, so that it can be passed in declaratively. Currently it's:

onFetch: null,

comment:2 Changed 9 years ago by haysmark

I agree with changing the declaration of onFetch, but to be consistent with existing uses of dojo.data, I suggest this change:

var cb = function(items, opts){
	...
	if(fetchArgs.onFetch){
		items = fetchArgs.onFetch.call(opts.scope, items, opts);
	}

onComplete takes a second argument that is missing in Select: the object that was passed to fetch. dojo.data enhances this object to contain everything the user could possibly need to know about the fetch, including the store. It just makes sense to pass this information along to onFetch. Similarly, it makes sense to respect the scope dojo.data assigns onComplete.

comment:3 Changed 9 years ago by bill

Owner: set to bill
Status: newassigned

Makes sense about passing in opts as the third argument (although it will seldom be accessed).

ISTM opts.scope == this unless the caller overrides scope in fetchArgs, but if the caller overrides scope, the onComplete() callback will fail since it expects "this" to point to the Select widget.

comment:4 Changed 9 years ago by bill

Resolution: fixed
Status: assignedclosed

(In [22492]) For setStore(), pass "this" to onFetch() callback. Also modified logic so that fetchArgs can't override onComplete() or scope, since that would break things. Fixes #11238 !strict.

comment:5 Changed 8 years ago by bill

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