Thanks, I'm on the right track then. I'm currently goofing around in
Drag.js looking at how it's done there.
On Sep 7, 2009, at 12:36 PM, Perrin Perrin wrote:
It won't detach the submit handler because you aren't detaching the
same function. Note you use bind() in the attach statement.
You could use the Binds mutator or do something along these lines.
in init function add this line
this.boundHandle =this.submit_handler.bind(this);
Then change attach and detach to use this.boundHandle instead.
On Mon, Sep 7, 2009 at 1:28 PM, rpflo <[email protected]> wrote:
Woops, my detach looks like this actually:
detach: function(){
this.form.removeEvent('submit',this.submit_handler);
return this;
},
On Sep 7, 12:23 pm, Ryan Florence <[email protected]> wrote:
> Here's a small class, my detach method doesn't work. I haven't done
> much with removeEvent, not sure what the problem is here. When I
call
> detach on the object, it doesn't detach the submit handler.
>
> Request.JSON.Form = new Class({
>
> Extends: Request.JSON,
>
> initialize: function(form,options){
> this.parent(options);
> this.form = $(form);
> this.options.url = this.form.get('action');
> this.attach();
> },
>
> attach: function(){
>
this.form.addEvent('submit',this.submit_handler.bind(this));
> return this;
> },
>
> detach: function(){
> this.form.removeEvent(this.submit_handler);
> return this;
> },
>
> submit_handler: function(event){
> event.stop();
> this.post(this.form);
> }
>
>
>
> });