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
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
Hello
I have a problem with adding event click to elements by class name.
I'm trying to add event onclick to all input tags that have class
compare_itm by this code:
$$('input.compare_itm').observe('click', myFunction);
But it doesn't work. Is it possible to do in Prototype ?
thanks
--
You
You are trying to apply a single method to a set of items. For this to work
you need to apply the same function to each member of the set using
invoke().
$$('input.compare_itm').invoke('observe', 'click', myFunction);
See also: http://api.prototypejs.org/language/enumerable/prototype/invoke/
TJ, I found that Form.EventObserver worked when I clicked submit but not
until.. same thing with FormObserver, 1.
On Mon, Aug 23, 2010 at 2:37 AM, T.J. Crowder t...@crowdersoftware.comwrote:
Hi,
You want Form.Observer, not Form.EventObserver, and you need to
provide an interval telling it
Hi,
The $$ function returns an array[1]. Arrays don't have an `observe`
method. However, Prototype does add an `invoke` method[2] to arrays by
mixing the Enumerable mix-in into them. So:
$$('input.compare_itm').invoke('observe', 'click', myFunction);
That said, you'll end up hooking the event
Indeed T.J. catching bubbling events is something I need to consider more
often.
Thanks for the heads up :-)
On Mon, Aug 23, 2010 at 10:05 AM, T.J. Crowder t...@crowdersoftware.comwrote:
Hi,
The $$ function returns an array[1]. Arrays don't have an `observe`
method. However, Prototype does
I'm not sure what you mean. I want to submit the login part using
enter, but I want it to use another action. I also want to submit the
registration form using enter, so outside the password field I don't
want to prevent the registration submit from executing.
Thanks.
On Aug 23, 2:51 am, Phil
You could also try to observe the form and prevent it from submitting:
YourFormElement.observe('submit', function submitEvent(event) {
event.stop(); // stops the form from actually submitting
// other code you would like to run
});
On Mon, Aug 23, 2010 at 10:24 AM, jhaagmans
thanks, it works !
Another question: how can I send element as argument to the click
function ?
I'm trying to use this:
$$('input.compare_itm').invoke('observe', 'click',
myFunction.bindAsEventListener('compare', this ));
function myFunction(group, elm){
alert(elm.value); // undefined
}
On Aug
Hi,
Another question: how can I send element as argument to the click
function ?
If you're using `observe`, Prototype ensures that within the event
handler, `this` refers to the element on which you called `observe`.
If you're using `on`, then the element will be the second argument to
your
11 matches
Mail list logo