Forum: Ruby on Rails Help with onComplete on Ajax.Request

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Francis S. (Guest)
on 2006-12-29 22:41

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

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

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(
        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;


This topic is locked and can not be replied to.