Hello, I'm curious to know if there's a way to apply script.aculo.us'
drop_receiving_element call to cater for multiple DOM IDs without
repeating too much code.
I'll give a little background for what I need to know for:
In a class at univeristy we are developing the interface and backend
for a multi-player online boardgame. We are using rails as our
framework as our lecturer is very much interested in how we can utilise
it. Basically the game is a 18x18 board and each user has 9 pieces to
start with.
Anyhow, I'm working on the UI and for a little spark I'm making use of
script.aculo.us helper methods. I made use of draggable_element for the
player pieces (paste below) and now I need to do the reverse with the
board.
<h1>Game Pieces</h1>
<% for piece in @pieces %>
<%= image_tag "/images/#{piece[:name]}", :id =>
"piece_#{piece[:id]}" %>
<%= draggable_element "piece_#{piece[:id]}", :revert
=> true %>
<% end %>
As the board is rather sizey I created the table with a small
javascript loop assigning each DOM an ID. Now when a user drags one of
their pieces into a box on the table an AJAX call is made and that id
is reloaded. As you may see applying the above loop is going to repeat
300+ and that's no good as I'm trying to cut down on overheads.
Is there a way to do this? I had a look at the script.aculo.us site and
seen something like what I'm after, however for draggables.
['about-bubble','ref-bubble','downloads-bubble','docs-bubble'].each(function(b){
new Draggable(b,{revert:true,handle:b+'-handle'});
});
It would be great if I could see how this is applied with rails.
Anyone advise on this would be great, and yes I have spent quite a
while Googling for solutions - no good however.
Thanks
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---