Correct use Event.on form submit

57 views
Skip to first unread message

kstubs

unread,
Jun 24, 2012, 1:03:36 PM6/24/12
to prototype-s...@googlegroups.com
Is this correct?

this.__z__handleSubmit = this.form.on('submit', this.__handleSubmit.bindAsEventListener(this)); 

Where:  __z__handleSubmit is my Event Handler
Where: __handleSubmit is the class method to bind to

Is the bindAsEventListener necessary?  I want to get back the Event Handler so I can later destroy it with:
this.__z__handleSubmit.stop(); 

Victor

unread,
Jun 26, 2012, 6:42:55 AM6/26/12
to prototype-s...@googlegroups.com
Is this correct?
this.__z__handleSubmit = this.form.on('submit', this.__handleSubmit.bindAsEventListener(this)); 
Is the bindAsEventListener necessary?  I want to get back the Event Handler so I can later destroy it with:
this.__z__handleSubmit.stop(); 
 
this.__handleSubmit.bind(this) should be enough

kstubs

unread,
Jun 26, 2012, 9:46:17 PM6/26/12
to prototype-s...@googlegroups.com
Victor,
That is not conveniently tied to any event handler, so what is the convenient means of disconnecting it, as in __eventHandler.stop(); ?
Karl..

Victor

unread,
Jun 27, 2012, 3:52:45 AM6/27/12
to prototype-s...@googlegroups.com
That is not conveniently tied to any event handler, so what is the convenient means of disconnecting it, as in __eventHandler.stop(); ?


Sorry, I've not completely understood this phrase. I'll repeat myself:

// start observer - bindAsEventListener isn't needed
this.__z__handleSubmit = this.form.on('submit', this.__handleSubmit.bind(this));
// stop observer
this.__z__handleSubmit.stop();

Reply all
Reply to author
Forward
0 new messages