ACK with comments below:

On Dec 2, 2010, at 2:27 PM, [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")}
> +  })

I have tested it and you don't have to use this beforeSend hooks. You can 
delete it.

> +  $(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)
> +        });
> +      }
> +    })
> +  })

The line with 'form = $(response)...' its better if you put 'var' before it 
like this:
> var form = $(response).find('#edit_dcloud_form')


In Javascript variables with var before the name are local otherwise global.

Otherwise good work. Like the size of the patch. :) Thumb's up!

> 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|
>     = render :partial => 'form', :locals => { :f => f }
>     %input{ :type => 'submit', :value => t(:save), :name => 'save_provider', 
> :id => 'save_provider' }
> diff --git a/src/app/views/providers/show.haml 
> b/src/app/views/providers/show.haml
> index 574aed8..44c3612 100644
> --- a/src/app/views/providers/show.haml
> +++ b/src/app/views/providers/show.haml
> @@ -3,7 +3,7 @@
>   %nav.subsubnav
>     = render_navigation(:level => 4)
>     %br
> -    %table
> +    %table#show_dcloud
>       %thead
>         %tr
>           %th{:scope => "col"} Provider Name
> -- 
> 1.7.2.3
> 
> _______________________________________________
> deltacloud-devel mailing list
> [email protected]
> https://fedorahosted.org/mailman/listinfo/deltacloud-devel

_______________________________________________
deltacloud-devel mailing list
[email protected]
https://fedorahosted.org/mailman/listinfo/deltacloud-devel

Reply via email to