Hi electronbender,

I've seen queekly your code and maybe the onComplete function,
passed to the request istance, doesn't know who is "chLip".

I think you have to use ".bind()" for that funcion...
Something like:
------------
onComplete: function(theData){
               this.set('html',theData.vest.cont);
       }.bind(chLip)
--------------

so now the "this" inside onComplete is the chLip and you can use
it's properties/funciotions.

Andrea

On Fri, Sep 17, 2010 at 14:45, electronbender <ognen.plavev...@gmail.com>wrote:

> I'm generating a list of articles like so:
>
> data.articles.each(function(article, ind){
> var chLi = new Element('li').inject(rootUl);
> var chA = new Element('a',{'href':'javascript:;'}).inject(chLi);;
> var chLih = new Element('h4').set('html',vest.title).inject(chA);;
> var chLip = new Element('p').set('html',vest.desc).inject(chLi);;
>
> chA.addEvent('click',function(){
>        var foo = new Request.JSONP({
>        url: 'http://phpscrape.plavevski.net/index.php?src=a1&t=2&dta=' +
> vest.link,
>        onComplete: function(theData){
>                chLip.set('html',theData.vest.cont);
>        }
>        });
>        foo.send();
> })
>
> The idea is that when a article title is clicked, the P tag html is
> overwritten with the data fetched from the JSONP.
> This works on the first click. The new html is loaded, and the P tag
> html replaced.
> If you click any other title after that, the first P tag html is
> overwritten instead of the second. And so with any subsequent link
> clicked.
>
> See it in action here: http://jsfiddle.net/PegsX/2/
>
> From what i gather, i am refferencing the correct tag:
>        onComplete: function(theData){
>                chLip.set('html',theData.vest.cont);
>        }
>
> But on execution only one and the same element is referenced?
> What am i doing wrong?
>

Reply via email to