I've made some comments and put in some debugging ... you should get an 
alert when you click an <li> now .. with the id ..

I've commented where the `this` scope changes for you .. to help you 
understand whats being done

I've also removed some unnessesary vars ..

Also its good practise (i recently discovered) to assign objects to a var 
then null the var afterwards as it frees up alo of memory in firefox at 
least (it saved me 40% or more) when i nulled the object ...
Here is some psuedo code ...

var req=new Ajax.Updater(suggestiveElement, '/SuggestiveSearch', {
         evalScripts: true,
         method: 'post',

       req=null; // null the object

To test this just make a periodical request simple one to a script that 
loads in about 50k of data without nulling the object and open windows task 
manager (with 1 firefox window open only) and goto processes and watch the 
memory usage of firefox .... test it for about a minute and watch the memory 
consumption of firefox go up by @ least 50k on every request ... (count the 
total memory after 1 minute !!)

Then close firefox and redo the script but with nulling the object and count 
the memory !!!

It speeds up pages and stops them hanging alot .. its unbelieveable how much 
memory it saves ... (firefox only unloads the memory after total browser 
close on all windows) but this unloads 40% of each request everytime a 
request is made so only 60% resides in memory not 100% ..

hope this helps

----- Original Message ----- 
From: "James Hoddinott" <[EMAIL PROTECTED]>
To: <prototype-scriptaculous@googlegroups.com>
Sent: Wednesday, November 05, 2008 12:05 PM
Subject: [Proto-Scripty] Re: In a bind...

> 2008/11/5 Alex Mcauley <[EMAIL PROTECTED]>:
>> can you re-post your full sourcecode for the funciton and the elements 
>> that
>> it produces and the elements you want to observe .. i will edit it for 
>> you
>> and put in some debugging for you
> So the javascript function (with your slight change) is:
> Event.observe(window,'load',function() {
>    new 
> Ajax.PeriodicalUpdater('dticketlist','data/fetchliveticketview.php',{
>// at this point `this` is the Ajax Object
>        decay:2,
>        onSuccess:function(e) { // `this` is now the ajax class object 
> (this.reponseText) !!
>            $$('li.clickinc').invoke('observe','click',function(evt) { // 
> the `this` scope is now moved to the element thats clicked
> alert('This: '+this.id+' Was clicked');
  //  var elm; //this is not needed
>             //   var id; // this is not needed
>            // this is not needed    elm = evt.element();
>            // this is not needed    id = elm.id || '(no id)';
>                $('dmain').update('Updated text after clicking on 
> '+this.id);
/* "this" contains the element object so you can get to its id with 
`this.id` and so on ... you can also reference it directly wiht 
$(this).toggle() ....or Element.toggle(this); or however you use your lib*/
>            })
>        }
>    });
> });
> The relevant part of the main HTML page is:
> <div id='dticketlist'>Loading...</div>
> <div id='dmain'></div>
> data/fetchliveticketview.php returns something like:
> <h6>Your Live Tickets</h6>
> <ul>
> <li id='M794751' class='clickinc'>M794751</li>
> <li id='M784800' class='clickinc'>M784800</li>
> <li id='M796555' class='clickinc'>M796555</li>
> <li id='M791122' class='clickinc'>M791122</li>
> <li id='M757562' class='clickinc'>M757562</li>
> <li id='M747790' class='clickinc'>M747790</li>
> </ul>
> <p>at 11:58:02</p>
> -- 
> James Hoddinott
> >

You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 

Reply via email to