diff --git a/app/controllers/authors_controller.rb b/app/controllers/authors_controller.rb
index 533b782..1c0ec9f 100644
--- a/app/controllers/authors_controller.rb
+++ b/app/controllers/authors_controller.rb
@@ -8,6 +8,10 @@ class AuthorsController < ApplicationController
def index
@authors = Author.paginate(page: params[:page])
@title = "Authors"
+ respond_to do |format|
+ format.html
+ format.js
+ end
end
end
diff --git a/app/controllers/books_controller.rb b/app/controllers/books_controller.rb
index a4a694f..5081477 100644
--- a/app/controllers/books_controller.rb
+++ b/app/controllers/books_controller.rb
@@ -8,6 +8,10 @@ class BooksController < ApplicationController
def index
@books = Book.paginate(page: params[:page])
@title = "Books"
+ respond_to do |format|
+ format.html
+ format.js
+ end
end
end
diff --git a/app/controllers/series_controller.rb b/app/controllers/series_controller.rb
index eb28280..a8bdbf7 100644
--- a/app/controllers/series_controller.rb
+++ b/app/controllers/series_controller.rb
@@ -8,6 +8,10 @@ class SeriesController < ApplicationController
def index
@series = Serie.paginate(page: params[:page])
@title = "Series"
+ respond_to do |format|
+ format.html
+ format.js
+ end
end
end
diff --git a/app/views/authors/_index.html.erb b/app/views/authors/_index.html.erb
new file mode 100644
index 0000000..7e36c98
--- /dev/null
+++ b/app/views/authors/_index.html.erb
@@ -0,0 +1,9 @@
+<%= will_paginate %>
+
+
+<% @authors.each do |author| %>
+ - <%= link_to author.name, author %>
+<% end %>
+
+
+<%= will_paginate %>
diff --git a/app/views/authors/index.html.erb b/app/views/authors/index.html.erb
index 322eff1..e8aefa0 100644
--- a/app/views/authors/index.html.erb
+++ b/app/views/authors/index.html.erb
@@ -1,11 +1,2 @@
Authors
-
-<%= will_paginate %>
-
-
-<% @authors.each do |author| %>
- - <%= link_to author.name, author %>
-<% end %>
-
-
-<%= will_paginate %>
+<%= render 'authors/index' %>
diff --git a/app/views/authors/index.js.erb b/app/views/authors/index.js.erb
new file mode 100644
index 0000000..41478db
--- /dev/null
+++ b/app/views/authors/index.js.erb
@@ -0,0 +1 @@
+$("#items").html("<%= escape_javascript(render('authors/index')) %>");
diff --git a/app/views/books/_index.html.erb b/app/views/books/_index.html.erb
new file mode 100644
index 0000000..03b71a5
--- /dev/null
+++ b/app/views/books/_index.html.erb
@@ -0,0 +1,12 @@
+<%= will_paginate %>
+
+
+ <% @books.each do |book| %>
+ -
+ <%= link_to book.title, book %>
+
+ <% end %>
+
+
+<%= will_paginate %>
+
diff --git a/app/views/books/index.html.erb b/app/views/books/index.html.erb
index 0c1deac..e21e41d 100644
--- a/app/views/books/index.html.erb
+++ b/app/views/books/index.html.erb
@@ -1,14 +1,2 @@
All books
-
-<%= will_paginate %>
-
-
- <% @books.each do |book| %>
- -
- <%= link_to book.title, book %>
-
- <% end %>
-
-
-<%= will_paginate %>
-
+<%= render 'books/index' %>
diff --git a/app/views/books/index.js.erb b/app/views/books/index.js.erb
new file mode 100644
index 0000000..71a51d0
--- /dev/null
+++ b/app/views/books/index.js.erb
@@ -0,0 +1 @@
+$("#items").html("<%= escape_javascript(render('books/index')) %>");
diff --git a/app/views/series/_index.html.erb b/app/views/series/_index.html.erb
new file mode 100644
index 0000000..45f0a89
--- /dev/null
+++ b/app/views/series/_index.html.erb
@@ -0,0 +1,9 @@
+<%= will_paginate %>
+
+
+<% @series.each do |serie| %>
+ - <%= link_to serie.name, serie %>
+<% end %>
+
+
+<%= will_paginate %>
diff --git a/app/views/series/index.html.erb b/app/views/series/index.html.erb
index a2241fa..4493078 100644
--- a/app/views/series/index.html.erb
+++ b/app/views/series/index.html.erb
@@ -1,11 +1,2 @@
Series
-
-<%= will_paginate %>
-
-
-<% @series.each do |serie| %>
- - <%= link_to serie.name, serie %>
-<% end %>
-
-
-<%= will_paginate %>
+<%= render 'series/index' %>
diff --git a/app/views/series/index.js.erb b/app/views/series/index.js.erb
new file mode 100644
index 0000000..4301451
--- /dev/null
+++ b/app/views/series/index.js.erb
@@ -0,0 +1 @@
+$("#items").html("<%= escape_javascript(render('series/index')) %>");
diff --git a/app/views/static_pages/home.html.erb b/app/views/static_pages/home.html.erb
index 12952a5..e7efe64 100644
--- a/app/views/static_pages/home.html.erb
+++ b/app/views/static_pages/home.html.erb
@@ -3,8 +3,10 @@
Browse <%= @books_count %> books
- <%= link_to "Books", books_path, class: "btn btn-lg btn-primary" %>
- <%= link_to "Authors", authors_path, class: "btn btn-lg btn-primary" %>
- <%= link_to "Series", series_path, class: "btn btn-lg btn-primary" %>
+ <%= link_to "Books", books_path, class: "btn btn-lg btn-primary", remote: true %>
+ <%= link_to "Authors", authors_path, class: "btn btn-lg btn-primary", remote: true %>
+ <%= link_to "Series", series_path, class: "btn btn-lg btn-primary", remote: true %>
+
+