--- server/public/javascripts/application.js | 30 ++++++++++++++++++++++++++++++ server/views/instances/index.html.haml | 3 ++- server/views/instances/show.html.haml | 3 ++- server/views/layout.html.haml | 2 ++ 4 files changed, 36 insertions(+), 2 deletions(-)
diff --git a/server/public/javascripts/application.js b/server/public/javascripts/application.js index fe45776..80e1d1c 100644 --- a/server/public/javascripts/application.js +++ b/server/public/javascripts/application.js @@ -1,2 +1,32 @@ // Place your application-specific JavaScript functions and classes here // This file is automatically included by javascript_include_tag :defaults + +$(document).ready(function() { + + $("a.delete").click(function(e) { + var original_url = $(this).attr('href') + $.ajax({ + url : original_url, + type : 'DELETE', + cache : false, + success: function(data) { + window.location = original_url.replace(//([\w_-]+)$/i, '') + } + }) + return false; + }) + + $("a.post").click(function(e) { + var original_url = $(this).attr('href') + $.ajax({ + url : original_url, + type : 'POST', + dataType : 'xml', + success: function(data) { + window.location = original_url.replace(//([\w_-]+)$/i, '') + } + }) + return false; + }) + +}) diff --git a/server/views/instances/index.html.haml b/server/views/instances/index.html.haml index 6f3996d..afc52c1 100644 --- a/server/views/instances/index.html.haml +++ b/server/views/instances/index.html.haml @@ -26,4 +26,5 @@ %td = instance.state %td - = instance.actions.collect { |a| link_to(a, self.send("#{a}_instance_url", instance.id), :method => :post)}.join(' ') + -instance.actions.each do |action| + =link_to action, self.send(:"#{action}_instance_url", instance.id), :class => instance_action_method(action) diff --git a/server/views/instances/show.html.haml b/server/views/instances/show.html.haml index dabcc61..f27dcb7 100644 --- a/server/views/instances/show.html.haml +++ b/server/views/instances/show.html.haml @@ -39,4 +39,5 @@ %di %dt %dd - = @instance.actions.collect { |action| link_to(action, "/api/instances/#{@instance.id}/#{action}") }.join(" ") + -@instance.actions.each do |action| + =link_to action, self.send(:"#{action}_instance_url", @instance.id), :class => instance_action_method(action) diff --git a/server/views/layout.html.haml b/server/views/layout.html.haml index a932caa..0f736fb 100644 --- a/server/views/layout.html.haml +++ b/server/views/layout.html.haml @@ -8,6 +8,8 @@ /[if lt IE 8] = stylesheet_link_tag '/stylesheets/compiled/ie.css', :media => 'screen, projection' = stylesheet_link_tag '/stylesheets/compiled/application.css', :media => 'screen, projection' + %script{:type => "text/javascript", :src => "/javascripts/jquery-1.4.2.min.js" } + %script{:type => "text/javascript", :src => "/javascripts/application.js" } %body #wrapper #header