diff --git a/app/controllers/articles_controller.rb b/app/controllers/articles_controller.rb
index 60602ee..395687a 100644
--- a/app/controllers/articles_controller.rb
+++ b/app/controllers/articles_controller.rb
@@ -62,7 +62,7 @@ def update
respond_to do |format|
if @article.update_attributes(params[:article])
- format.html { redirect_to(@article, :notice => 'Article was successfully updated.') }
+ format.html { redirect_to(articles_path, :notice => 'Article was successfully updated.') }
format.xml { head :ok }
else
format.html { render :action => "edit" }
diff --git a/app/views/articles/_article.html.erb b/app/views/articles/_article.html.erb
index edf405a..56eaec5 100644
--- a/app/views/articles/_article.html.erb
+++ b/app/views/articles/_article.html.erb
@@ -1,6 +1,6 @@
| <%= article.title %> |
<%= link_to 'Show', article %> |
- <%= link_to 'Edit', edit_article_path(article) %> |
+ <%= link_to 'Edit', edit_article_path(article), :class => 'modal' %> |
<%= link_to 'Destroy', article, :confirm => 'Are you sure?', :method => :delete %> |
diff --git a/app/views/articles/_update-form.html.erb b/app/views/articles/_update-form.html.erb
new file mode 100644
index 0000000..7e6b1eb
--- /dev/null
+++ b/app/views/articles/_update-form.html.erb
@@ -0,0 +1,21 @@
+<%= form_for @article do |f| %>
+ <% if @article.errors.any? %>
+
+
<%= pluralize(@article.errors.count, "error") %> prohibited this article from being saved:
+
+
+ <% @article.errors.full_messages.each do |msg| %>
+ - <%= msg %>
+ <% end %>
+
+
+ <% end %>
+
+
+ <%= f.label :title %>
+ <%= f.text_field :title %>
+
+
+ <%= f.submit %>
+
+<% end %>
diff --git a/app/views/articles/create.js.erb b/app/views/articles/create.js.erb
index 86d9d97..b5a1d15 100644
--- a/app/views/articles/create.js.erb
+++ b/app/views/articles/create.js.erb
@@ -6,4 +6,5 @@
$('#dialog-form').dialog('close');
$('#dialog-form').remove();
$('table').append('<%= escape_javascript(render(@article)) %>');
+ $('table tr:last .modal').click(attatchModal());
<%- end %>
diff --git a/app/views/articles/edit.html.erb b/app/views/articles/edit.html.erb
index 2c19833..926a706 100644
--- a/app/views/articles/edit.html.erb
+++ b/app/views/articles/edit.html.erb
@@ -1,6 +1,8 @@
-Editing article
+
+
Editing article
-<%= render 'form' %>
+ <%= render 'update-form' %>
-<%= link_to 'Show', @article %> |
-<%= link_to 'Back', articles_path %>
+ <%= link_to 'Show', @article %> |
+ <%= link_to 'Back', articles_path %>
+
\ No newline at end of file
diff --git a/app/views/articles/index.html.erb b/app/views/articles/index.html.erb
index 41d5d4e..85bf5aa 100644
--- a/app/views/articles/index.html.erb
+++ b/app/views/articles/index.html.erb
@@ -13,4 +13,4 @@
-<%= link_to 'New Article', new_article_path, :id => 'create_article' %>
+<%= link_to 'New Article', new_article_path, :class => 'modal' %>
diff --git a/public/javascripts/application.js b/public/javascripts/application.js
index 20c83fb..273a3f7 100644
--- a/public/javascripts/application.js
+++ b/public/javascripts/application.js
@@ -1,13 +1,15 @@
// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults
-$(document).ready(function() {
- $('#create_article').click(function(e) {
+function attatchModal() {
+ $('.modal').click(function(e) {
var url = $(this).attr('href');
var dialog_form = $('Loading form...
').dialog({
autoOpen: false,
width: 520,
modal: true,
+ show: 'fade',
+ hide: 'drop',
open: function() {
return $(this).load(url + ' #content');
},
@@ -18,4 +20,8 @@ $(document).ready(function() {
dialog_form.dialog('open');
e.preventDefault();
});
-});
+}
+
+$(document).ready(function() {
+ attatchModal();
+});
\ No newline at end of file