On 02/12/10 18:15, Ladislav Martincik wrote: > > On Dec 2, 2010, at 3:56 PM, [email protected] wrote: > >> On 02/12/10 16:31, Ladislav Martincik wrote: >>> >>> On Dec 2, 2010, at 3:10 PM, Michal Fojtik wrote: >>> >>>> On 02/12/10 14:27 +0100, [email protected] wrote: >>>>> From: Jozef Zigmund<[email protected]> >>>>> >>>>> --- >>>>> src/app/views/providers/_providers.haml | 16 ++++++++++++++++ >>>>> src/app/views/providers/edit.haml | 2 +- >>>>> src/app/views/providers/show.haml | 2 +- >>>>> 3 files changed, 18 insertions(+), 2 deletions(-) >>>>> >>>>> diff --git a/src/app/views/providers/_providers.haml >>>>> b/src/app/views/providers/_providers.haml >>>>> index 5587a34..07b5e40 100644 >>>>> --- a/src/app/views/providers/_providers.haml >>>>> +++ b/src/app/views/providers/_providers.haml >>>>> @@ -12,3 +12,19 @@ >>>>> %input{ :type => 'submit', :value => t(:add), :disabled => >>>>> ('disabled' unless controller.action_name == 'index') } >>>>> - form_tag({:controller => 'providers', :action => 'destroy', :id >>>>> => @provider}, {:method => :delete , :class => 'buttononly'}) do >>>>> = submit_tag 'delete', :disabled => ('disabled' unless @provider >>>>> and controller.action_name == 'show') >>>>> + >>>>> +:javascript >>>>> + jQuery.ajaxSetup({ 'beforeSend': function(xhr) >>>>> {xhr.setRequestHeader("Accept", "text/javascript")} >>>>> + }) >>>>> + $(document).ready( function () { >>>>> + $("a.button").click(function (event) { >>>>> + event.preventDefault() >>>>> + if (!$(this).attr("disabled")) { >>>>> + $.get(($(this).attr("href")), function (response) { >>>>> + form = $(response).find('#edit_dcloud_form') >>>>> + $("#show_dcloud").replaceWith(form) >>>>> + $('a.button').attr('disabled', true) >>>>> + }); >>>>> + } >>>>> + }) >>>>> + }) >>>>> diff --git a/src/app/views/providers/edit.haml >>>>> b/src/app/views/providers/edit.haml >>>>> index 199a73a..2691bfa 100644 >>>>> --- a/src/app/views/providers/edit.haml >>>>> +++ b/src/app/views/providers/edit.haml >>>>> @@ -2,6 +2,6 @@ >>>>> #details.grid_13 >>>>> %nav.subsubnav >>>>> = render_navigation(:level => 4) >>>>> - - form_for :provider, @provider, :url => provider_path(@provider), >>>>> :html => { :method => 'put', :class => "dcloud_form" } do |f| >>>>> + - form_for :provider, @provider, :url => provider_path(@provider), >>>>> :html => { :id => 'edit_dcloud_form', :method => 'put', :class => >>>>> "dcloud_form" } do |f| >>>> >>>> I'm not sure if 'PUT' method is actually supported by browsers. For this >>>> case I recommending to use 'method overide' in Rails. >>>> >>> >>> I believe it should be fine. All new browsers (even IE6) supports HTTP/1.1. >> >> not sure if i misunderstood - Michal is referring to HTML forms - they >> support only 'GET' and 'POST' for the method attribute (i think HTML 5 >> will add support for all CRUD methods). So in this case, if this is >> really a html form and you want to do a put using the form then you need >> to use method_override... if it is working its because it defaults to >> 'post' and so you might not notice it, >> >> marios > > HTML forms are mapped to HTTP protocol so still there's no need to worry.
Well, in this case, it is mapped to POST > so still there's no need to worry. At least I would be very surprised that something like this simple doesn't work. ;) It *will* work, because its doing a *POST* so in all likelyhood the intended outcome is the same. > The questions maybe should be what is the software we have to support (I mean browsers mainly) in order to determine if this is the case. I would argue that the question should be, do you need to do a PUT? If yes, use method_override. If you are fine with doing a POST, then leave it as it is, marios > _______________________________________________ deltacloud-devel mailing list [email protected] https://fedorahosted.org/mailman/listinfo/deltacloud-devel
