I’m attmepting to follow the Agile Web D. book but frankly the
AJAX section is pretty awful. When it comes to the drag and drop bit why
doesn’t it tell you what the actions in the controller should be? I’ve
checked script.aculo.us and that’s not helped either. Can someone help?
Here is my code:
#arrange.rhtml
Main Column | Side Column |
---|---|
<%= render :partial => 'main_col_items' %>
|
<%= render :partial => 'side_col_items' %>
|
<%= drop_receiving_element(‘main_col_items’,
:accept => ‘side_col_item’,
:complete => “$(‘spinner’).hide();”,
:before => “$(‘spinner’).show();”,
:hoverclass => ‘hover’,
:with => “‘artic=’ +
encodeURIComponent(element.id.split(’_’).last())’”,
:url => {:action=>:main_col })%>
<%= drop_receiving_element(‘side_col_items’,
:accept => ‘main_col_item’,
:complete => “$(‘spinner’).hide();”,
:before => “$(‘spinner’).show();”,
:hoverclass => ‘hover’,
:with => “‘artic=’ +
encodeURIComponent(element.id.split(’_’).last())’”,
:url => {:action=>:side_col} )%>
#---------------------------------
_main_col_items.rhtml
<% @issue.articles.each do |article| %>
<% if article.column == ‘main’ %>
<% ma_id = “art_#{article.id}” %>
<%= draggable_element(ma_id, :ghosting=>true, :revert=>true) %>
<% end %>
<% end %>
#---------------------------------
_side_col_items.rhtml
<% @issue.articles.each do |article| %>
<% if article.column != ‘main’ %>
<% si_id = “art_#{article.id}” %>
<%= draggable_element(si_id, :ghosting=>true, :revert=>true) %>
<% end %>
<% end %>
#---------------------------------
issue_controller.rb
def arrange
@issue = Issue.find(params[:id])
end
def main_col
article = Article.update(params[:artic], :column => “main”)
end
def side_col
article = Article.update(params[:artic], :column => “side”)
end
My problem is that nothing seems to occure for those actions, main_col
and side_col. Is params[:artic] not right? Surely this value will hold
the id from the element being dragged?
Any help would be much appreciated.
Cheers
Theo