It seems I have to combine a both approaches to achieve what I need - whether or not this should be improved within the tapestry framework is up for debate....

<t:datefield t:id="selectedDateElem" id="selectedDateElem" onchange="alert('1 onchange attribute');" />

        $("selectedDateElem").observe("change", function(event)
            {
                alert("2 change observer");
            });

        document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
            {
if (Tapestry.currentFocusField && Tapestry.currentFocusField.id == "selectedDateElem")
                    alert("3 focus change observer");
            });

Test Case 1:

User clicks into input field
user alters value of input field
user clicks out of input field
--> "1 onchange attribute" & "2 change observer"

Test case 2:
User clicks datepicker icon
user selects a new date from popup
--> "3 focus change observer"

So the onchange attribute is equivalent to the change observer, therefore the only complete solution is to combine approaches 2 & 3:

         $("selectedDateElem").observe("change", function(event)
            {
                Page.dateFieldChanged();
            });

        document.observe(Tapestry.FOCUS_CHANGE_EVENT, function(event)
            {
if (Tapestry.currentFocusField && Tapestry.currentFocusField.id == "selectedDateElem")
                    Page.dateFieldChanged();
            });

I think it would be nice if datefield, or tapestry's focus-change handler would trigger the "change" event for the datefield's input, I had assumed this was the point if jira 1844 ..

should I log a new jira to request this?

On 20/08/2012 11:49 PM, François Facon wrote:
Hi Paul

In 5.3 DatePicker (DateField.js) save  informations in
Tapestry.currentFocusField and fire the Tapestry.FOCUS_CHANGE_EVENT
like this
document.fire(Tapestry.FOCUS_CHANGE_EVENT, this.field);

what about listen to tapestry:focuschange like the
Tapestry.FieldEventManager (tapestry.js) do?

document.observe("tapestry:focuschange", function(event)
                                                  {
                                                                if(     
Tapestry.currentFocusField!=undefined)
                                                        
alert(Tapestry.currentFocusField.id);
                                                 });
                                
Regards
François

2012/8/20, Paul Stanton <p...@mapshed.com.au>:
Thanks brian, but i am assuming/hoping that the fix for issue 1844
allows me to do something a little more obvious.

if not, i'm sure to use your solution.

p.

On 20/08/2012 9:16 PM, Bryan Lewis wrote:
Ah yes, the problem of not catching changes made by clicking on the
little
calendar icon.  Here's a crude work-around I'm using in 5.2.6, catching
the
click event.

      String scriptlet = "Event.observe('" + dateFieldId + "-trigger',
'click', function() { setChanged(true); });"
      javaScriptSupport.addScript(scriptlet);

I wanted only to detect whether there'd been a change, to protect the
user
from leaving the page without saving.  It's not perfect because the user
might click the icon without actually making a change, but for my needs
it's okay.

I left a to-do note to myself a couple of years ago, "The fix might be to
add an unload event on the form that checks whether any of the date
values
changed," but I don't know if that still makes sense.


On Mon, Aug 20, 2012 at 6:34 AM, Paul Stanton <p...@mapshed.com.au>
wrote:

I've just tried that too howard,

$("selectedDate").observe("**change", function(event)
                      {
                          alert('here');
                      });

However this is only fired when you type into the input field and the
click out (blur) .. not when a date is selected via the popup
calendar...

I have stepped through the js code via firebug and can see that the jira
1844 patch is being executed, however my handler is never called...

if someone could give me a little working eg that would be great!

thanks.


On 20/08/2012 4:56 PM, Howard Lewis Ship wrote:

Have you tried observing the change event? The onchange attr may get
overwritten by the date field JS.

On Sunday, August 19, 2012, Paul Stanton wrote:

   Hi all,
I've found the bug report: https://issues.apache.org/**
jira/browse/TAP5-1844
<https://issues.apache.org/**jira/browse/TAP5-1844<https://issues.apache.org/jira/browse/TAP5-1844>
.. and am using tapestry 5.3.3 so the fix has been applied, however I
still can't get tapestry to call my 'onchange' handler.

<t:datefield value="dateValue" onchange="alert('here');" />

Is there some extra wiring required?

Thanks, Paul.

------------------------------****----------------------------**
--**---------
To unsubscribe, e-mail:
users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
For additional commands, e-mail: users-h...@tapestry.apache.org



------------------------------**------------------------------**---------

To unsubscribe, e-mail:
users-unsubscribe@tapestry.**apache.org<users-unsubscr...@tapestry.apache.org>
For additional commands, e-mail: users-h...@tapestry.apache.org



---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to