hi, i can''t figure out how to solve this problem: i do a an ajax.updater, it works but i would like that the message returned by the server "lives" only for 5-10 seconds and then disappears.(like in Gmail, when you send/delete/etc a message a new line appears for few second and then it disappears). this is my function: function addgr(){ var gr=$F(''form''); var url= ''page.php''; var par = ''add='' + gr ; var target = $(''msg'');//the meassage that has to appear for 5-7 seconds var addingr = new Ajax.Updater(target,url,{method: ''get'',parameters : par}); } thanks. cirpo --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Use the onSuccess handler of your Ajax object to set a timeout to remove the information you added. For example: new Ajax.Updater("message_area", "get_new_message.php", { onSuccess: function() { setTimout("clear_message_area", 5000); } }); function clear_message_area() { $("message_area").update(""); } The onSuccess handler sets a timeout of 5 seconds (the number is in milliseconds) after which it calls the clear_message_area() function. That function then simply updates the content of the message_area element with nothing effectively removing the message from the screen. -- Dash -- cirpo wrote:> hi, i can''t figure out how to solve this problem: > i do a an ajax.updater, it works but i would like that the message > returned by the server "lives" only for 5-10 seconds and then > disappears.(like in Gmail, when you send/delete/etc a message a new > line appears for few second and then it disappears). > > this is my function: > function addgr(){ > var gr=$F(''form''); > var url= ''page.php''; > var par = ''add='' + gr ; > var target = $(''msg'');//the meassage that has to appear for 5-7 > seconds > var addingr = new Ajax.Updater(target,url,{method: > ''get'',parameters : par}); > } > > > thanks. > > cirpo > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
thanks! it works! i tried to find setTimeout in the docs, but i found nothing... keep on looking for thanks again cirpo --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
cirpo a écrit :> i tried to find setTimeout in the docs, but i found nothing... > keep on looking forNavigator DOM. Try this: http://developer.mozilla.org/en/docs/DOM:window.setTimeout -- Christophe Porteneuve a.k.a. TDD "[They] did not know it was impossible, so they did it." --Mark Twain Email: tdd-x+CfDp/qHev2eFz/2MeuCQ@public.gmane.org --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
As Christophe indicated, setTimeout isn''t part of Prototype.js -- it''s actually just part of JavaScript. If you search for "javascript setTimeout" you''ll get more information. There''s also a relatively strong article at about.com regarding the similarities and differences between setTimeout() and setInterval(): http://javascript.about.com/library/blstvsi.htm -- Dash -- cirpo wrote:> thanks! > it works! > > i tried to find setTimeout in the docs, but i found nothing... > keep on looking for > > > > thanks again > > > cirpo > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
thanks,thanks,thanks it''s only one month that i started web programming and i''m still learning... thanks for your support and sorry for my bad/wrong english. cirpo --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On Apr 11, 9:36 am, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote:> As Christophe indicated, setTimeout isn''t part of Prototype.js -- it''s > actually just part of JavaScript.Nope, it''s part of DOM Level 0, it''s a method of the window object. -- Rob --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
On 10 avr, 11:26, "cirpo" <alessandro.cine...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> hi, i can''t figure out how to solve this problem: > i do a an ajax.updater, it works but i would like that the message > returned by the server "lives" only for 5-10 seconds and then > disappears.(like in Gmail, when you send/delete/etc a message a new > line appears for few second and then it disappears). > > this is my function: > function addgr(){ > var gr=$F(''form''); > var url= ''page.php''; > var par = ''add='' + gr ; > var target = $(''msg'');//the meassage that has to appear for 5-7 > seconds > var addingr = new Ajax.Updater(target,url,{method: > ''get'',parameters : par}); > } > > thanks. > > cirpoWhat you are trying to do is more a problem of server response, you shouldn''t make the client take care of how long a response should last. The server should be responsible of that task since that it is it who is responsable of the control flow in your app/Web page. I had to implement a similar system in my app, and since Prototype is a nice framework, he will handle whatever the server ask it to do automatically. Consider this : var options = { method: ''get'', parameters: par, requestHeaders: [''object'', ''TestUpdater''], // optional... evalScripts: true // execute any embedded scripts in the response }; new Ajax.Updater( ''msg'', ''page.php'', options ); And a typical response would be : <div id="msg3434323466792"> <b>Response is : </b>Hello world ! <script type="text/javascript"> setTimeout( function() { Element.remove(''msg3434323466792''); }, 5 * 60 * 1000 ); </script> </div> Since we did set ''evalScripts'' to ''true'', any <script> tag found will be removed and executed. The response should have, then, a tag with a very unique Id (usually composed from a timestamp) and the script executed by the update method of prototype creates a timer that will remove that tag later on. This way, you decouple your client from the responsibility of "cleaning up" the server responses. After all, it doesn''t matter from who, when, or where the request originated ; the client should only ask question, and handle events, not control the behavior of the interface. Hope this helps. -Yanick --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---
Yes Rob, you''re right. In David''s defense, though, he was perhaps indicating that the solution could be found in nearly every Javascript book or tutorial ever written. Even those from the "dark ages" when Netscape Navigator was the hottest browser around. I don''t have much faith that someone lacking knowledge of setTimeout (and, it would seem, the ability to Google it) would understand the phrase "DOM Level 0." Besides, he''d be correct in saying the method will exist in every major modern browser implementation of Javascript. Cut the guy some slack. For most (hobbyist) programmers, the ubiquitously implemented BOM/DOM standards **are** "Javascript." I can understand the desire to be precise. I''m obsessive/compulsive/ passive/aggressive/etc. that way too. =) TAG On Apr 11, 2007, at 1:26 AM, RobG wrote:> On Apr 11, 9:36 am, David Dashifen Kees <dashi...-NT0ononE2K1Wk0Htik3J/w@public.gmane.org> wrote: >> As Christophe indicated, setTimeout isn''t part of Prototype.js -- >> it''s >> actually just part of JavaScript. > > Nope, it''s part of DOM Level 0, it''s a method of the window object.--~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-spinoffs-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-spinoffs-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-spinoffs?hl=en -~----------~----~----~----~------~----~------~--~---