display items on home page (AJAX)

This commit is contained in:
Meutel 2015-06-29 18:58:02 +02:00
parent ee56518217
commit d629153e0f
13 changed files with 53 additions and 36 deletions

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -0,0 +1,9 @@
<%= will_paginate %>
<ul class="authors">
<% @authors.each do |author| %>
<li><%= link_to author.name, author %></li>
<% end %>
</ul>
<%= will_paginate %>

View File

@ -1,11 +1,2 @@
<h1>Authors</h1>
<%= will_paginate %>
<ul class="authors">
<% @authors.each do |author| %>
<li><%= link_to author.name, author %></li>
<% end %>
</ul>
<%= will_paginate %>
<%= render 'authors/index' %>

View File

@ -0,0 +1 @@
$("#items").html("<%= escape_javascript(render('authors/index')) %>");

View File

@ -0,0 +1,12 @@
<%= will_paginate %>
<ul class="books">
<% @books.each do |book| %>
<li>
<%= link_to book.title, book %>
</li>
<% end %>
</ul>
<%= will_paginate %>

View File

@ -1,14 +1,2 @@
<h1>All books</h1>
<%= will_paginate %>
<ul class="books">
<% @books.each do |book| %>
<li>
<%= link_to book.title, book %>
</li>
<% end %>
</ul>
<%= will_paginate %>
<%= render 'books/index' %>

View File

@ -0,0 +1 @@
$("#items").html("<%= escape_javascript(render('books/index')) %>");

View File

@ -0,0 +1,9 @@
<%= will_paginate %>
<ul class="series">
<% @series.each do |serie| %>
<li><%= link_to serie.name, serie %></li>
<% end %>
</ul>
<%= will_paginate %>

View File

@ -1,11 +1,2 @@
<h1>Series</h1>
<%= will_paginate %>
<ul class="series">
<% @series.each do |serie| %>
<li><%= link_to serie.name, serie %></li>
<% end %>
</ul>
<%= will_paginate %>
<%= render 'series/index' %>

View File

@ -0,0 +1 @@
$("#items").html("<%= escape_javascript(render('series/index')) %>");

View File

@ -3,8 +3,10 @@
<h2>Browse <%= @books_count %> books</h2>
<p>
<%= 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 %>
</p>
</div>
<div class="center container-fluid" id="items">
</div>