Opened 10 years ago

Closed 10 years ago

Last modified 9 years ago

#10013 closed enhancement (wontfix)

dijit.form.TextBox delayed onChange

Reported by: Marcin Gołębski Owned by: Douglas Hays
Priority: high Milestone: future
Component: Dijit - Form Version: 1.3.2
Keywords: TextBox delay Cc: dante
Blocked By: Blocking:

Description

It will be nice to have callback function which is invocked some delay after last input changed (like in dijit.form.FilteringSelect?).

The patch attached introduces such functionality.

Attachments (1)

TextBox.patch (1.6 KB) - added by Marcin Gołębski 10 years ago.

Download all attachments as: .zip

Change History (13)

Changed 10 years ago by Marcin Gołębski

Attachment: TextBox.patch added

comment:1 Changed 10 years ago by Adam Peller

Why not just connect a function with setTimeout to the onChange event?

comment:2 in reply to:  1 Changed 10 years ago by Marcin Gołębski

For simplicity reasons. You have to mantain timer object, check if it is already fired, or not. My solution just do it for you.

comment:3 Changed 10 years ago by bill

I just don't understand why you want this? onChange only fires after the input blurs, right?

comment:4 in reply to:  3 Changed 10 years ago by Marcin Gołębski

Replying to bill:

I just don't understand why you want this? onChange only fires after the input blurs, right?

You right, onChange fires when:

  • input blurs or
  • on every character when intermediateChanges==true

but, when you wan to use TextBox? as a entry box for filtering for instance DataGrid? you want to do filter precedure not on every character or after user exit TextBox?, but after user finishes typing.

comment:5 Changed 10 years ago by Douglas Hays

Milestone: tbdfuture

comment:6 Changed 10 years ago by Douglas Hays

Owner: set to Douglas Hays

comment:7 Changed 10 years ago by Adam Peller

Resolution: wontfix
Status: newclosed

we can't mark this future unless we understand the need for this enhancement. please reopen if necessary.

comment:8 Changed 10 years ago by Adam Peller

ok, sorry, I missed the previous comment. I still feel that this doesn't belong in the base class functionality. It would be much better if we had a generic facility for dealing with events and reducing them to fire on an interval.

comment:9 Changed 10 years ago by bill

That's what http://dojocampus.org/content/2009/09/28/rate-limiting-with-javascript/ is about, BTW.

I do see the reason for the request but it probably doesn't belong in the base code of dijit. If we get more requests for it maybe we can reconsider.

As for the example of filtering data in the grid (basically doing for Grid what ComboBox does natively), it seems like you would want a better solution than just a delayed onChange. For example, if the user types "ca" and then pauses (and thus you start a query to filter the Grid to entries matching "ca"), but then before the query returns the user starts typing more letters, then wouldn't you want to cancel the in-flight query?

comment:10 in reply to:  8 ; Changed 10 years ago by Marcin Gołębski

Replying to peller:

I still feel that this doesn't belong in the base class functionality.

Ok, I don't want to insist. I haven't feel the spirit of digit yet :)

comment:11 in reply to:  10 Changed 10 years ago by Adam Peller

Cc: dante added

Replying to mgolebsk:

Ok, I don't want to insist. I haven't feel the spirit of digit yet :)

The spirit is to keep built-in options limited and code small, while making it possible to do things by extension. Take a look at Pete's article and see if it provides a more generic but still elegant approach. If not, we can revisit this.

comment:12 Changed 9 years ago by bill

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