Hi,
I have a class that has a function that will send an Ajax call to the
server and on the onComplete handler is still on the same class.
Problem is, i can''t seem to access the class'' variables inside
the
method.
Is this possible at all? Because from what i''ve read, the onComplete
handler should be a global function. I want it inside the class since i
have to also dynamically adjust the class attributes based on the
response.
Here is a snippet of the class:
CommentProcessor = Class.create();
CommentProcessor.prototype = {
cell_element: null,
input_element: null,
anchor_element: null,
commentable_type: null,
submit_input_field: function(){
var url = ''/prototype/add_comment'';
var pars = ''commentable_type='' + this.commentable_type
+
''&comment='' +
this.input_element.value;
var myAjax = new Ajax.Request(
url,
{
method: ''post'',
parameters: pars,
//how do i call the handler function here?
onComplete: this.handlerFunc(this)
});
return false;
},
handlerFunc: function(t) {
this.anchor_element.innerHTML = t.responseText;
}
};
Thanks,
/franee
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---