Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Updating a timepicker control via text input

255 views
Skip to first unread message

Greg Allen

unread,
Jun 2, 2010, 12:15:02 PM6/2/10
to
I have the following control in my XUL application:

<timepicker id="time-picker"
onchange="alert('time-picker: ' +
this.dateValue);"
hideseconds="true">


I'm having problems where the control doesn't seem to be updating correctly.

If I change the values in the control using the up/down arrows and the
mouse, the alerts
contain the modified values.

However, if I use the keyboard, enter text in one of the fields (for
example, change the hour),
and then hit tab, the alert does *not* reflect the changes.

Why does text input not get reflected in the control values? It does
display the value
correctly, but when you query the control for "dateValue" or other it does
not match
what is displayed.

What am I doing wrong?

Thanks,

-- Greg


JY

unread,
Jun 2, 2010, 1:08:02 PM6/2/10
to
did you check whether either $('time-picker').value or
$('time-picker').getAttribute('value') has the correct kbd-edited date ?

-jy
(just guessing quickly)

Greg Allen

unread,
Jun 2, 2010, 1:30:57 PM6/2/10
to
I just did. None of those has the new value - all have the old value.

For example, say I start with 1:00. I change this to 2:00, I still get 1:00
in
my alert. If I then change to 3:00, I get 2:00 in my alert.

It's almost as if the value isn't really changed, or reflected in the
control, until the
onchange event has completed. But why would it work with the up/down arrows
then?

-- Greg

"JY" <j...@zooc.org> wrote in message
news:Wsednb6htPYLEpvR...@mozilla.org...

Daniel Kirsch

unread,
Jun 2, 2010, 2:11:24 PM6/2/10
to
Am 02.06.2010 19:30, schrieb Greg Allen:
> I just did. None of those has the new value - all have the old value.

Greg, the dateValue will be set when the change event fires, however
this is not the case as long as you have the focus in the field. See the
datetimepicker.xml binding.

Daniel

Greg Allen

unread,
Jun 2, 2010, 3:38:43 PM6/2/10
to
Hi Daniel,

This still doesn't seem right. The change event *is* firing, which is why I
see my alert. But
the value has not been updated.

I have tried clicking on another control too, but that still shows me the
wrong value. So
whether I tab or click on another control the change event does fire, but
the value is
not right.

Or do I have to handle the focus event (which one is that?) to get the
value? That doesn't seem
right to me...

-- Greg

"Daniel Kirsch" <Iwillnotr...@gmx.de> wrote in message
news:aaGdncSae4VTA5vR...@mozilla.org...

Igor Tandetnik

unread,
Jun 2, 2010, 4:09:48 PM6/2/10
to
Greg Allen <gregor...@sierraatlantic.com> wrote:
> I have the following control in my XUL application:
>
> <timepicker id="time-picker"
> onchange="alert('time-picker: ' +
> this.dateValue);"
> hideseconds="true">
>
>
> I'm having problems where the control doesn't seem to be updating
> correctly.

Try something like this:

onchange="var picker=this; window.setTimeout(function() { alert(picker.dateValue); }, 0);"

My guess is, the control itself handles onchange event to update its internal data from the text you've just entered - but your handler happens to fire first. setTimeout delays your processing until all other event handlers got a go at the event.

Igor Tandetnik

Neil

unread,
Jun 2, 2010, 4:21:43 PM6/2/10
to
Igor Tandetnik wrote:

>My guess is, the control itself handles onchange event to update its internal data from the text you've just entered - but your handler happens to fire first.
>

That sounds like a bug that should be fixed (probably in this case the
control should capture the change event so that it receives it before
the onchange attribute).

--
Warning: May contain traces of nuts.

0 new messages