Why dont you pass the whole json object into a function and have the function do all the work - this way you can extract ID's..

Or why not use a classname and do it on each of those...

Alex Mcauley
http://www.thevacancymarket.com
----- Original Message ----- From: "Richard Quadling" <rquadl...@gmail.com>
To: <prototype-scriptaculous@googlegroups.com>
Sent: Tuesday, June 08, 2010 11:50 AM
Subject: [Proto-Scripty] Adding an effect to AJAX'd data.


Hi.

I've got a simple little page I'm building for our fleet inspectors.
Trying to make it look nicer.

The issue I'm coming up against is the single threaded nature of
JavaScript (I think that's the issue I coming up against).

The onSuccess() callback reads Response.responseJSON.Order.Details and
uses a template to add the details to the page.

The template is ...

var tmpl_Wheel = new Template('<div class="vsWheel"
style="display:none"
id="Wheel_#{Wheel}"><h2>#{Position}</h2><div>#{Description}</div><div>#{Serial}</div><div>#{Date}</div><div>#{Supplier}</div><div>#{Depot}</div></div>');

As you can see, the style is display:none, so that I can add a
progressive reveal to the wheels.

The trouble is, I can't call the new Effect.Appear('Wheel_' + Wheel)
because it doesn't exist yet.

So.

I've got the "add the wheels to the display" code as ...

var s_Wheels = '';
o_Response.responseJSON.Order.each(function(o_Wheel){
s_Wheels = s_Wheels + tmpl_Wheel.evaluate(o_Wheel);
});
$('vsWheels').update(s_Wheels);

And then I want to add the effect.

o_Response.responseJSON.Order.each(function(o_Wheel){
new Effect.Appear(
'Wheel_' + o_Wheel.Wheel,{
delay    : 0.25 * parseInt(o_Wheel.Wheel, 10),
duration : 0.50,
from     : 0.00,
to       : 1.00
}
);
});


Initially, the effect was in the same loop (with each wheel being
updated as it went).

But this isn't working either.

What options do I have for this?

Essentially, the data comes in via AJAX and I want it to appear one
wheel at a time, with each wheel being slightly delayed so that they
appear smoothly.

Regards,

Richard Quadling.
--
-----
Richard Quadling
"Standing on the shoulders of some very clever giants!"
EE : http://www.experts-exchange.com/M_248814.html
EE4Free : http://www.experts-exchange.com/becomeAnExpert.jsp
Zend Certified Engineer : http://zend.com/zce.php?c=ZEND002498&r=213474731
ZOPA : http://uk.zopa.com/member/RQuadling

--
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-scriptacul...@googlegroups.com. To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/prototype-scriptaculous?hl=en.



--
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-scriptacul...@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to