My restful delete links work in everything except IE7, in which case the
delete works, but then it redirects back to the ''href'' that
was on the
delete link. I''ve even tested this with regular restful scaffold and i
still get the same behavior.
Link RHTML:
<%= link_to(image_tag("delete.png", :border=>0,
:alt=>"Delete List"),
{:controller => ''lists'',
:action=>''destroy'', :id=>@list},
{:confirm=>''Are you sure you want to delete this list?'',
:method=>"delete"}) %>
Link Output:
<a href="/lists/22" onclick="if (confirm(''Are you
sure you want to
delete this list?'')) { var f =
document.createElement(''form'');
f.style.display = ''none''; this.parentNode.appendChild(f);
f.method ''POST''; f.action = this.href;var m =
document.createElement(''input'');
m.setAttribute(''type'', ''hidden'');
m.setAttribute(''name'', ''_method'');
m.setAttribute(''value'', ''delete'');
f.appendChild(m);f.submit(); };return
false;"><img alt="Delete List" border="0"
src="/images/delete.png?1189326914" /></a>
Destroy Method:
# DELETE /lists/1
# DELETE /lists/1.xml
def destroy
@list = List.find(params[:id])
@list.destroy
respond_to do |format|
flash[:notice] = "List <strong>#{@list.name}</strong> was
successfully deleted."
format.html { redirect_to lists_path }
format.xml { head :ok }
end
end
Routes:
map.resources :lists,:member=>{:print=>:get}, :collection => {:order
=>
:put} do |list|
list.resources :categories, :collection => {:order => :put} do
|category|
category.resources :items, :collection => {:order => :put}
end
end
When you click delete, it runs through destroy, destroys the list, and
then instead of redirecting to lists_path, it redirects to /lists/[id]
which is the href on the delete link. This behavior is ONLY in IE7. IE6
works fine, as do firefox and safari.
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---