Hi i need to scroll to the bottom of a <ul> with a static height (filled by PHP) i tried $(''Last'').scrollTo(); and new Element.scrollTo(''Last''); but both don''t work this ist the code from the html page: <script type="text/javascript" src="lib/prototype.js"></script> <script type="text/javascript" src="lib/scriptaculous.js"></script> <script type="text/javascript"> var name = null; function loadList(){ new Ajax.Updater("Debug", "update.html"); new Ajax.Updater("Liste", "load_chat_final.php"); new Ajax.Updater("Debug", "ready.html"); new Element.scrollTo("Last", {duration: 2.0}); } function sendList(){ name = $F("User"); var params = "User="+$F("User")+"&Msg="+escape($F("Msg")); new Ajax.Request("update_chat_final.php", { method: "get", parameters: params, onComplete: afterSending }); return false; } function afterSending(){ $("Msg").value = ""; loadList(); } function init(){ loadList(); new PeriodicalExecuter(loadList, 2); /* new Element.scrollTo("Last", {duration: 2.0});*/ } Event.observe(window, "load", init); </script> </head> <body> <h1>C-Coders Chat</h1> <div id="Ausgabe"> <ul id="Liste"></ul> </div> <form onsubmit="return sendList();" method="get"> <fieldset> <legend>Eingabe:</legend> <label for="User">Name:</label> <input type="text" name="User" id="User" /> <input type="text" name="Msg" id="Msg" size="80" /> <input type="submit" id="Submit" value="abschicken" /> </fieldset> <div id="Debug"></div> </form> </body> </html> --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
I don''t see an element with an id of "Last". That''s what you''re telling it to scroll to--it doesn''t exist, it won''t happen. If the element is added by the Ajax.Updaters, give us the current HTML after that occurs--we can''t duplicate your AJAX requests. Also, why three Ajax.update calls immediately during window.onload? That seems like a waste of network resources. Put the content in the file in the first place. TAG On Jun 26, 2007, at 2:37 PM, burni wrote:> > Hi > > i need to scroll to the bottom of a <ul> with a static height (filled > by PHP) > > i tried $(''Last'').scrollTo(); > and new Element.scrollTo(''Last''); > but both don''t work > > > this ist the code from the html page: > > > > > <script type="text/javascript" src="lib/prototype.js"></script> > <script type="text/javascript" src="lib/scriptaculous.js"></script> > <script type="text/javascript"> > var name = null; > > function loadList(){ > new Ajax.Updater("Debug", "update.html"); > new Ajax.Updater("Liste", "load_chat_final.php"); > new Ajax.Updater("Debug", "ready.html"); > new Element.scrollTo("Last", {duration: 2.0}); > } > > function sendList(){ > name = $F("User"); > var params = "User="+$F("User")+"&Msg="+escape($F("Msg")); > new Ajax.Request("update_chat_final.php", { > method: "get", > parameters: params, > onComplete: afterSending > }); > return false; > } > > function afterSending(){ > $("Msg").value = ""; > loadList(); > } > > function init(){ > loadList(); > new PeriodicalExecuter(loadList, 2); > /* new Element.scrollTo("Last", {duration: 2.0});*/ > } > > > > > Event.observe(window, "load", init); > > </script> > </head> > > <body> > <h1>C-Coders Chat</h1> > <div id="Ausgabe"> > <ul id="Liste"></ul> > > </div> > <form onsubmit="return sendList();" method="get"> > <fieldset> > <legend>Eingabe:</legend> > <label for="User">Name:</label> > <input type="text" name="User" id="User" /> > <input type="text" name="Msg" id="Msg" size="80" /> > <input type="submit" id="Submit" value="abschicken" /> > </fieldset> > <div id="Debug"></div> > </form> > </body> > </html> > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
the <span id="Last">last</span> is generated by the php script at the bottom of the <ul> the list is saved in $list and i an array generated with php&mysql, followed by: array_unshift($list, "<div id=\"Last\"> LAST</div>"); $list = array_reverse($list); echo implode("", $list); On 26 Jun., 22:56, Tom Gregory <t...-PGZyUNKar/Q@public.gmane.org> wrote:> I don''t see an element with an id of "Last". That''s what you''re > telling it to scroll to--it doesn''t exist, it won''t happen. > > If the element is added by the Ajax.Updaters, give us the current > HTML after that occurs--we can''t duplicate your AJAX requests. > > Also, why three Ajax.update calls immediately during window.onload? > That seems like a waste of network resources. Put the content in the > file in the first place. > > TAG > > On Jun 26, 2007, at 2:37 PM, burni wrote: > > > > > Hi > > > i need to scroll to the bottom of a <ul> with a static height (filled > > by PHP) > > > i tried $(''Last'').scrollTo(); > > and new Element.scrollTo(''Last''); > > but both don''t work > > > this ist the code from the html page: > > > <script type="text/javascript" src="lib/prototype.js"></script> > > <script type="text/javascript" src="lib/scriptaculous.js"></script> > > <script type="text/javascript"> > > var name = null; > > > function loadList(){ > > new Ajax.Updater("Debug", "update.html"); > > new Ajax.Updater("Liste", "load_chat_final.php"); > > new Ajax.Updater("Debug", "ready.html"); > > new Element.scrollTo("Last", {duration: 2.0}); > > } > > > function sendList(){ > > name = $F("User"); > > var params = "User="+$F("User")+"&Msg="+escape($F("Msg")); > > new Ajax.Request("update_chat_final.php", { > > method: "get", > > parameters: params, > > onComplete: afterSending > > }); > > return false; > > } > > > function afterSending(){ > > $("Msg").value = ""; > > loadList(); > > } > > > function init(){ > > loadList(); > > new PeriodicalExecuter(loadList, 2); > > /* new Element.scrollTo("Last", {duration: 2.0});*/ > > } > > > Event.observe(window, "load", init); > > > </script> > > </head> > > > <body> > > <h1>C-Coders Chat</h1> > > <div id="Ausgabe"> > > <ul id="Liste"></ul> > > > </div> > > <form onsubmit="return sendList();" method="get"> > > <fieldset> > > <legend>Eingabe:</legend> > > <label for="User">Name:</label> > > <input type="text" name="User" id="User" /> > > <input type="text" name="Msg" id="Msg" size="80" /> > > <input type="submit" id="Submit" value="abschicken" /> > > </fieldset> > > <div id="Debug"></div> > > </form> > > </body> > > </html>--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---