On Thursday 17 May 2007 20:59, Jesse Farmer wrote:
> Similarly you could do the Ajax stuff first and use the onComplete or
> onSuccess callbacks to then invoke the effect.
>
I'd strongly advise this. If you delete the element locally, and then send a 
request back to the server to delete from the DB, you run the risk of the 
request failing, and your UI getting out of synch. 

To rephrase Tom Gregory's example solution to call the Ajax first (also 
untested etc.):

new Ajax.Updater(
  'id_of_list_master_container',
  'hello.php',
  { parameters: 'ID='+id_of_element,
     onComplete:function(response){
        var deletables=document.getElementsByClassName
           ('deleteMe','id_of_list_master_container');
         deletables.each(
            function(item){
              new Effect.Fade(item);
            }
         );
     }
  }

This is assuming that your hello.php script will return a HTML list of all 
items in the list, including the ones you've just deleted, and mark the 
deleted ones with a CSS class 'deleteMe'. document.getElementsByClassName() 
then finds each of these elements within the container, and applies a Fade 
effect to each of them. 

If refreshing the list has a possibility of adding new items in as well, then 
you could mark them with a CSS class too, and apply an Effect.Appear() or 
whatever to add an extra bit of bling - I mean helpful user notification. :-)

HTH

Dave
-- 
----------------------
Author
Ajax in Action http://manning.com/crane
Ajax in Practice http://manning.com/crane2
Prototype & Scriptaculous in Action http://manning.com/crane3

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Spinoffs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-spinoffs?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to