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 <[EMAIL PROTECTED]> 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 [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
-~----------~----~----~----~------~----~------~--~---