Article View: pl.comp.lang.javascript
Article #51093Re: object + callback = problem
From: witold.zywica
Date: Tue, 17 Apr 2012 12:07
Date: Tue, 17 Apr 2012 12:07
25 lines
1886 bytes
1886 bytes
W dniu wtorek, 17 kwietnia 2012 13:13:29 UTC+2 użytkownik satellite napisał:
> On 2012-04-17 11:50, Witold Zywica wrote:
>
> o, w tym wypadku wydaje mi sie ze problem jest tu :
>
> > this.loadData = function () {
> > $.getJSON('skrypt.php', this.callback);
> > }
>
> this w getJson jest this getJson - a nie Twojej funkcji - ale mozesz
> uniknac 'porywania' this, w taki np. sposob :
>
> function test(){
>
> var that = this;
>
> that.loadData = function () {
> $.getJSON('skrypt.php', that.callback);
> }
>
>
> }
Niestety nie wiele pomogło :(
Firebug pluje mi komunikatem, który mowi ze wewnątrz funkcji loadDataCallback this nie jest zdefiniowane. Jak mogę dostać się do składników obiektu z tej funkcji?
Technical Details
Message-ID:
<32049575.2339.1334664478199.JavaMail.geo-discussion-forums@ynbq18>Path:
mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin1!goblin.stu.neva.ru!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mailReferences:
<fd024171-140c-4cb5-885b-4ca0ceacf3fa@z17g2000yqf.googlegroups.com> <jmjj8p$oun$1@inews.gazeta.pl>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-archive.icm.edu.pl!news.icm.edu.pl!news.nask.pl!news.nask.org.pl!goblin1!goblin.stu.neva.ru!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: witold.zywica@gmail.com Newsgroups: pl.comp.lang.javascript Subject: Re: object + callback = problem Date: Tue, 17 Apr 2012 05:07:58 -0700 (PDT) Organization: http://groups.google.com Lines: 28 Message-ID: <32049575.2339.1334664478199.JavaMail.geo-discussion-forums@ynbq18> References: <fd024171-140c-4cb5-885b-4ca0ceacf3fa@z17g2000yqf.googlegroups.com> <jmjj8p$oun$1@inews.gazeta.pl> NNTP-Posting-Host: 194.251.119.198 Mime-Version: 1.0 X-Trace: posting.google.com 1334664903 11659 127.0.0.1 (17 Apr 2012 12:15:03 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Tue, 17 Apr 2012 12:15:03 +0000 (UTC) In-Reply-To: <jmjj8p$oun$1@inews.gazeta.pl> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=194.251.119.198; posting-account=GCQVcgoAAADjp-6CvhS4IjykuPgElWlE User-Agent: G2/1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit