Aljosa Mohorovic schrieb:
> i'm trying to access "this"/object from ajax callback function, any
> idea/approach on how to achieve this?
> 
> replace "this._items" in callback function with working code, any tips
> appreciated.
> function test() {
>       this._items = {};
>       
>       this.load_item = function(name, url) {
>               $.get(url, function(o) { this._items[name] = o; } );
>       }
> }
> 
> var t = new test();
> t.load_item('test', 'test.html');


I assume this snippet is part of a larger object. Otherwise Mike's 
solution is fine I guess.

Try:

function test() {
        this._items = {};
        
         var self = this;
        this.load_item = function(name, url) {
                $.get(url, function(o) { self._items[name] = o; } );
        }
}

-- Klaus

_______________________________________________
jQuery mailing list
[email protected]
http://jquery.com/discuss/

Reply via email to