DmitryPush wrote:
> Hi,
> You just cat you following in your view:
> <%= link_to 'Destroy', photo, :confirm => 'Are you sure?', :method
> => :delete %>
> and it appear in browser to that:
> <a onclick="if (confirm('Are you sure?')) { 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);var s =
> document.createElement('input'); s.setAttribute('type', 'hidden');
> s.setAttribute('name', 'authenticity_token'); s.setAttribute('value',
> 'LgNwcxaXQ3+NT95f1SJYo1ZOUfXMFtQimzSzDmjJM3g=');
> f.appendChild(s);f.submit(); };return false;" href="/photos/
> 51">Destroy</a>
> 
> as you can see its still post, but it has hidden input that tells your
> controller about delete.

Ah yes, of course, i had the feeling that rails handled this with a bit 
of subterfuge but couldn't remember quite how.  I actually tried this 
with a link_to_remote and the generated html was just a call to 
jQuery.ajax with the delete method, just as i'd done it already, rather 
than the code you posted up.  I wonder if this is an issue with the 
jrails plugin, which overrides the javascript generated by rails' remote 
helpers.

I'm actually doing it in javascript (in a jQuery.ajax call) anyway, so 
lets see if changing the method to post and adding "_method=delete" to 
the data has the same effect...yes it does.  Great, thanks Dmitry!
-- 
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 [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-talk?hl=en.

Reply via email to