TJ, thanks for your help on the Form.EventObserver. The non-timed version is simply not being activated until the submit button is clicked so I had to use the timed version. I hate doing that because of the cpu overhead but we gotta do what works.
My next question on event observers is unloading them. This creates the form observer: new Form.Observer('myform', 0.5, updateMessage); BUT this does not remove it: Event.stopObserving('myform', 0.5, updateMessage); If you're using ajax for forms, you create an event observer, update the form (result of a save, initial load etc.) then the event observer gets triggered because the form data is changed (which all makes sense) BUT the fact that you can't force a reserialize so that new changes can be detected is kinda lame and leaves one with the only apparent option of removing the event observer, making changes and then reinstalling a new observer. So, what's the trick to uninstalling the form.eventobserver? Thanks! Pete On Mon, Aug 23, 2010 at 2:51 AM, T.J. Crowder <t...@crowdersoftware.com>wrote: > Hi, > > ...although despite the API docs saying *nothing* about it, > Form.EventObserver looks like it might do what you want on an event > (rather than timed) basis. Note that that may not necessarily do what > you want because it uses the `change` event on `select` and `text` > boxes, which is only fired by some browsers when the select/text box > loses focus (not on keypress). The timed check done by Form.Observer > happens more proactively (but -- especially on IE -- can be a drain on > the CPU). > > But I would expect this (your quoted code with a </script> tag removed > from the middle of it) to *basically* work: > > new Form.EventObserver($("myform"), updateFormMessage); > function updateFormMessage() { > $('myform_msg').innerHTML = "Click the Save button to save your new > settings."; > alert("Form Changed!"); > } > > ...and in fact: > http://jsbin.com/aboxu4 > > HTH, > -- > T.J. Crowder > Independent Software Consultant > tj / crowder software / com > www.crowdersoftware.com > > > On Aug 23, 7:37 am, "T.J. Crowder" <t...@crowdersoftware.com> wrote: > > Hi, > > > > You want Form.Observer, not Form.EventObserver, and you need to > > provide an interval telling it how often to check the form for > > changes. It happens that your use case *is* the example used on > > Form.Observer:http://api.prototypejs.org/dom/form/observer/ > > > > HTH, > > -- > > T.J. Crowder > > Independent Software Consultant > > tj / crowder software / comwww.crowdersoftware.com > > > > On Aug 23, 12:36 am, Phil Petree <phil.pet...@gmail.com> wrote: > > > > > > > > > Hey All! > > > > > I'm trying to implement a Form.EventObserver that will change a message > > > within the form. By default the message says: "These are your current > > > settings." and when a key is pressed I want the message to get changed > to > > > say "Click the Save button to save your new settings." > > > > > I have the function that sets the form message and its working just > fine > > > (gets called from other routines like during an ajax onComplete). > > > > > My problem is that I can not get the Form.EventObserver to call my > routine. > > > > > I have tried putting this in the form header, in a .js file that gets > > > included specifically for this form and inline just below the form > (which is > > > what most examples show) and nadda... zip... zilch... nothing! No > errors > > > and it absolutely doesn't get called! > > > > > // this code was used in the header and inline, strip off the <script> > tags > > > and the > > > // raw javascript code was tried in the included form_name.js file > > > <script type="text/javascript"> > > > new Form.EventObserver($("myform"), updateFormMessage); > > > </script> > > > function updateFormMessage() { > > > $('myform_msg').innerHTML = "Click the Save button to save your new > > > settings."; > > > alert("Form Changed!"); > > > > > } > > > > > Any suggestions would be appreciated! > > > > > Thanks, > > > > > Pete > > -- > You received this message because you are subscribed to the Google Groups > "Prototype & script.aculo.us" group. > To post to this group, send email to > prototype-scriptacul...@googlegroups.com. > To unsubscribe from this group, send email to > prototype-scriptaculous+unsubscr...@googlegroups.com<prototype-scriptaculous%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/prototype-scriptaculous?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Prototype & script.aculo.us" group. To post to this group, send email to prototype-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.