Nic
2008-Jan-16 13:10 UTC
igoogle/netvibes/pageflakes panels using scriptaculous/php+mysql
Hello Guys, I''m in the middle of creating this sort of solution using the scriptaculous framework and mysql to save the panel positions. The only problem i am facing here (which i was after some suggestions) is that i can setup the interface only if the list (using sortables.create) for the panels is hardcoded into the main page with an sql loop loading the panels. the problem with this setup is - you cannot add a panel to the group via ajax and save it''s position without reloading the page - as the query is on the main panels page. eg -------------------------------------- SELECT * FROM panels ORDER BY panelpos ASC <ul id="col1"> <?php do { ?> <li id="col1_<?php panelID; ?>"> <div id="pContent_<?php panelID; ?>">{load panel contents in here via ajax call|}</div> </li> </li> <?php } while ($row_rsCol1 = mysql_fetch_assoc($rsCol1)); ?> </ul> <script type="text/javascript"> Sortable.create("col1", { onUpdate: function() { new Ajax.Request("update-panel-positions.php", { method: "post", parameters: { data: Sortable.serialize("col1")} </script> -------------------------------------- If i try to put the above list inside an ajax request, then my sortables.create code doesn''t work becuase it is trying to execute ajax inside ajax. Does this make sense? --- - - - - - - - - - -- -- - - ----- Thank you in advance. Nic --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Markus Hammer
2008-Jan-16 15:18 UTC
Re: igoogle/netvibes/pageflakes panels using scriptaculous/php+mysql
Adding my 2 cents, allthough at the moment i am not actively working in any prototype based project. It seems to me you are complicating the panels. Imho it would be better if you would seperate the panel content from any javascript. The ajax request is better used and reusable if it just returns html and no javascript. The classes/functions for sortable creation and adding/deleting/moving should all happen on the main page. 1) your php creates the html source <div id="mypanels"> <div id="col_panel1" class="panel"></div> <div id="col_panel2" class="panel"></div> </div> 2) after page is loaded, your javascript starts and iterates through all panel divs inside mypanels and calls their ajax controllers (you seem to use id''s here), you update the contents and turn them into sortables. 3) now you just add create/delete functions and youre done. On 16 Jan., 14:10, Nic <morley....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Hello Guys, > > I''m in the middle of creating this sort of solution using the > scriptaculous framework and mysql to save the panel positions. > > The only problem i am facing here (which i was after some suggestions) > is that i can setup the interface only if the list (using > sortables.create) for the panels is hardcoded into the main page with > an sql loop loading the panels. > > the problem with this setup is - you cannot add a panel to the group > via ajax and save it''s position without reloading the page - as the > query is on the main panels page. > > eg > -------------------------------------- > SELECT * FROM panels ORDER BY panelpos ASC > > <ul id="col1"> > <?php do { ?> > <li id="col1_<?php panelID; ?>"> > <div id="pContent_<?php panelID; ?>">{load panel contents in here > via ajax call|}</div> > </li> > </li> > <?php } while ($row_rsCol1 = mysql_fetch_assoc($rsCol1)); ?> > </ul> > > <script type="text/javascript"> > > Sortable.create("col1", { > onUpdate: function() { > new Ajax.Request("update-panel-positions.php", { > method: "post", > parameters: { data: Sortable.serialize("col1")} > > </script> > > -------------------------------------- > > If i try to put the above list inside an ajax request, then my > sortables.create code doesn''t work becuase it is trying to execute > ajax inside ajax. > > Does this make sense? > --- - - - - - - - - - -- -- - - ----- > Thank you in advance. > Nic--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sébastien Gruhier
2008-Jan-16 15:36 UTC
Re: igoogle/netvibes/pageflakes panels using scriptaculous/php+mysql
try this http://blog.xilinus.com/2007/8/26/prototype-portal-class http://blog.xilinus.com/2007/9/4/prototype-portal-class-2 Seb On Jan 16, 2008, at 4:18 PM, Markus Hammer wrote:> > Adding my 2 cents, allthough at the moment i am not actively working > in any prototype based project. > > It seems to me you are complicating the panels. > > Imho it would be better if you would seperate the panel content from > any javascript. The ajax request is better used and reusable if it > just returns html and no javascript. > > The classes/functions for sortable creation and adding/deleting/moving > should all happen on the main page. > > 1) your php creates the html source > <div id="mypanels"> > <div id="col_panel1" class="panel"></div> > <div id="col_panel2" class="panel"></div> > </div> > 2) after page is loaded, your javascript starts and iterates through > all panel divs inside mypanels and calls their ajax controllers (you > seem to use id''s here), you update the contents and turn them into > sortables. > 3) now you just add create/delete functions and youre done. > > On 16 Jan., 14:10, Nic <morley....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: >> Hello Guys, >> >> I''m in the middle of creating this sort of solution using the >> scriptaculous framework and mysql to save the panel positions. >> >> The only problem i am facing here (which i was after some >> suggestions) >> is that i can setup the interface only if the list (using >> sortables.create) for the panels is hardcoded into the main page with >> an sql loop loading the panels. >> >> the problem with this setup is - you cannot add a panel to the group >> via ajax and save it''s position without reloading the page - as the >> query is on the main panels page. >> >> eg >> -------------------------------------- >> SELECT * FROM panels ORDER BY panelpos ASC >> >> <ul id="col1"> >> <?php do { ?> >> <li id="col1_<?php panelID; ?>"> >> <div id="pContent_<?php panelID; ?>">{load panel contents in here >> via ajax call|}</div> >> </li> >> </li> >> <?php } while ($row_rsCol1 = mysql_fetch_assoc($rsCol1)); ?> >> </ul> >> >> <script type="text/javascript"> >> >> Sortable.create("col1", { >> onUpdate: function() { >> new Ajax.Request("update-panel-positions.php", { >> method: "post", >> parameters: { data: Sortable.serialize("col1")} >> >> </script> >> >> -------------------------------------- >> >> If i try to put the above list inside an ajax request, then my >> sortables.create code doesn''t work becuase it is trying to execute >> ajax inside ajax. >> >> Does this make sense? >> --- - - - - - - - - - -- -- - - ----- >> Thank you in advance. >> Nic > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Nicholas Morley
2008-Jan-16 23:08 UTC
Re: igoogle/netvibes/pageflakes panels using scriptaculous/php+mysql
Thanks Seb. I was more looking to use the scriptaculous class. but i''ll check into the links. I suppose i need to understand more when and when not to use ajax. For example - the contents of the panels: would I use ajax to load the panel contents, as the netvibes site does, so that it loads all the empty panels, then as you wait longer it proceeds to load in the panel contents. but then would that mean by loading the panel contents in via ajax that each panel couldn''t contain any javascript? am i looking at this in the wrong way? Thanks guy very much for your help! On Jan 17, 2008 1:36 AM, Sébastien Gruhier <sgruhier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> > try this > http://blog.xilinus.com/2007/8/26/prototype-portal-class > http://blog.xilinus.com/2007/9/4/prototype-portal-class-2 > > > Seb > On Jan 16, 2008, at 4:18 PM, Markus Hammer wrote: > > > > > Adding my 2 cents, allthough at the moment i am not actively working > > in any prototype based project. > > > > It seems to me you are complicating the panels. > > > > Imho it would be better if you would seperate the panel content from > > any javascript. The ajax request is better used and reusable if it > > just returns html and no javascript. > > > > The classes/functions for sortable creation and adding/deleting/moving > > should all happen on the main page. > > > > 1) your php creates the html source > > <div id="mypanels"> > > <div id="col_panel1" class="panel"></div> > > <div id="col_panel2" class="panel"></div> > > </div> > > 2) after page is loaded, your javascript starts and iterates through > > all panel divs inside mypanels and calls their ajax controllers (you > > seem to use id''s here), you update the contents and turn them into > > sortables. > > 3) now you just add create/delete functions and youre done. > > > > On 16 Jan., 14:10, Nic <morley....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hello Guys, > >> > >> I''m in the middle of creating this sort of solution using the > >> scriptaculous framework and mysql to save the panel positions. > >> > >> The only problem i am facing here (which i was after some > >> suggestions) > >> is that i can setup the interface only if the list (using > >> sortables.create) for the panels is hardcoded into the main page with > >> an sql loop loading the panels. > >> > >> the problem with this setup is - you cannot add a panel to the group > >> via ajax and save it''s position without reloading the page - as the > >> query is on the main panels page. > >> > >> eg > >> -------------------------------------- > >> SELECT * FROM panels ORDER BY panelpos ASC > >> > >> <ul id="col1"> > >> <?php do { ?> > >> <li id="col1_<?php panelID; ?>"> > >> <div id="pContent_<?php panelID; ?>">{load panel contents in here > >> via ajax call|}</div> > >> </li> > >> </li> > >> <?php } while ($row_rsCol1 = mysql_fetch_assoc($rsCol1)); ?> > >> </ul> > >> > >> <script type="text/javascript"> > >> > >> Sortable.create("col1", { > >> onUpdate: function() { > >> new Ajax.Request("update-panel-positions.php", { > >> method: "post", > >> parameters: { data: Sortable.serialize("col1")} > >> > >> </script> > >> > >> -------------------------------------- > >> > >> If i try to put the above list inside an ajax request, then my > >> sortables.create code doesn''t work becuase it is trying to execute > >> ajax inside ajax. > >> > >> Does this make sense? > >> --- - - - - - - - - - -- -- - - ----- > >> Thank you in advance. > >> Nic > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Sébastien Gruhier
2008-Jan-17 06:19 UTC
Re: igoogle/netvibes/pageflakes panels using scriptaculous/php+mysql
You can do ajax content or not, it''s up to you. what do you want to do? if you use ajax content, your server response can contain javascript, it will be evaluated. Tell me more how you want to use, I could help you more Seb On Jan 17, 2008, at 12:08 AM, Nicholas Morley wrote:> Thanks Seb. > I was more looking to use the scriptaculous class. but i''ll check > into the links. > > I suppose i need to understand more when and when not to use ajax. > For example - the contents of the panels: would I use ajax to load > the panel contents, as the netvibes site does, so that it loads all > the empty panels, then as you wait longer it proceeds to load in > the panel contents. > > but then would that mean by loading the panel contents in via ajax > that each panel couldn''t contain any javascript? > > am i looking at this in the wrong way? > > Thanks guy very much for your help! > > On Jan 17, 2008 1:36 AM, Sébastien Gruhier <sgruhier-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > try this > http://blog.xilinus.com/2007/8/26/prototype-portal-class > http://blog.xilinus.com/2007/9/4/prototype-portal-class-2 > > > Seb > On Jan 16, 2008, at 4:18 PM, Markus Hammer wrote: > > > > > Adding my 2 cents, allthough at the moment i am not actively working > > in any prototype based project. > > > > It seems to me you are complicating the panels. > > > > Imho it would be better if you would seperate the panel content from > > any javascript. The ajax request is better used and reusable if it > > just returns html and no javascript. > > > > The classes/functions for sortable creation and adding/deleting/ > moving > > should all happen on the main page. > > > > 1) your php creates the html source > > <div id="mypanels"> > > <div id="col_panel1" class="panel"></div> > > <div id="col_panel2" class="panel"></div> > > </div> > > 2) after page is loaded, your javascript starts and iterates through > > all panel divs inside mypanels and calls their ajax controllers (you > > seem to use id''s here), you update the contents and turn them into > > sortables. > > 3) now you just add create/delete functions and youre done. > > > > On 16 Jan., 14:10, Nic < morley....-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > >> Hello Guys, > >> > >> I''m in the middle of creating this sort of solution using the > >> scriptaculous framework and mysql to save the panel positions. > >> > >> The only problem i am facing here (which i was after some > >> suggestions) > >> is that i can setup the interface only if the list (using > >> sortables.create) for the panels is hardcoded into the main page > with > >> an sql loop loading the panels. > >> > >> the problem with this setup is - you cannot add a panel to the > group > >> via ajax and save it''s position without reloading the page - as the > >> query is on the main panels page. > >> > >> eg > >> -------------------------------------- > >> SELECT * FROM panels ORDER BY panelpos ASC > >> > >> <ul id="col1"> > >> <?php do { ?> > >> <li id="col1_<?php panelID; ?>"> > >> <div id="pContent_<?php panelID; ?>">{load panel contents in here > >> via ajax call|}</div> > >> </li> > >> </li> > >> <?php } while ($row_rsCol1 = mysql_fetch_assoc($rsCol1)); ?> > >> </ul> > >> > >> <script type="text/javascript"> > >> > >> Sortable.create("col1", { > >> onUpdate: function() { > >> new Ajax.Request("update-panel-positions.php", { > >> method: "post", > >> parameters: { data: Sortable.serialize("col1")} > >> > >> </script> > >> > >> -------------------------------------- > >> > >> If i try to put the above list inside an ajax request, then my > >> sortables.create code doesn''t work becuase it is trying to execute > >> ajax inside ajax. > >> > >> Does this make sense? > >> --- - - - - - - - - - -- -- - - ----- > >> Thank you in advance. > >> Nic > > > > > > > >--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---