I am having a problem with an Object using closures, and referencing
the "this" reference from within the closure.

$.extend(MyObject.prototype, {
        save: function(id) {
                var html="some html";
                $.post( 'post_page.php', {'id':id, 'c':html},
                        function(data) {
                                this.save_complete(data.div_id, data.content);
                        }, 'json');

        save_complete: function( id, content ) {
                alert( "saved: " + id );
        }
});

If I call save() on this object, and the AJAX call happens, the "this"
reference does not refer to the instance of MyObject - which is what
I'm trying to do.  Is there any way around this?

Thanks!

- pc

Reply via email to