I have a list of pages from which I want to delete one. This I want to
do with draggable/droppable(trash can like). Which, strange enough,
does not work.
This does work:
{{{
link_to_remote("delete", :url => project_wiki_page_path(@project,
page), :method => :delete, :title =>project_wiki_page_path(@project,
page))
}}}
But this doesn''t:
{{{
<script
type="text/javascript">Droppables.add("drop_wp", {
onDrop:function(element){
new Ajax.Request(''''+element.title, {asynchronous:true,
evalScripts:true, method:''delete''});
}
});
</script>
}}}
Note that we are using plain prototype here because at the moment the
page is generated on the server we do not yet know what the URL might
be.
They both give exactly(!) the same parameters in the generated
request, and they both invoke destroy. However, the second function
invokes the show method with the id of the page that was deleted, thus
giving an error, we just deleted that item! It doesn''t obey the
redirect.
The destroy function looks like this:
{{{
def destroy
@page = @project.pages.find(params[:id])
@page.destroy
redirect_to(index)
end
}}}
We are using Scriptaculous version 1.8, Prototype version 1.6 and
Rails Edge.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---