display items on home page (AJAX)
This commit is contained in:
parent
ee56518217
commit
d629153e0f
@ -8,6 +8,10 @@ class AuthorsController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@authors = Author.paginate(page: params[:page])
|
@authors = Author.paginate(page: params[:page])
|
||||||
@title = "Authors"
|
@title = "Authors"
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,10 @@ class BooksController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@books = Book.paginate(page: params[:page])
|
@books = Book.paginate(page: params[:page])
|
||||||
@title = "Books"
|
@title = "Books"
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
@ -8,6 +8,10 @@ class SeriesController < ApplicationController
|
|||||||
def index
|
def index
|
||||||
@series = Serie.paginate(page: params[:page])
|
@series = Serie.paginate(page: params[:page])
|
||||||
@title = "Series"
|
@title = "Series"
|
||||||
|
respond_to do |format|
|
||||||
|
format.html
|
||||||
|
format.js
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
9
app/views/authors/_index.html.erb
Normal file
9
app/views/authors/_index.html.erb
Normal 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 %>
|
@ -1,11 +1,2 @@
|
|||||||
<h1>Authors</h1>
|
<h1>Authors</h1>
|
||||||
|
<%= render 'authors/index' %>
|
||||||
<%= will_paginate %>
|
|
||||||
|
|
||||||
<ul class="authors">
|
|
||||||
<% @authors.each do |author| %>
|
|
||||||
<li><%= link_to author.name, author %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= will_paginate %>
|
|
||||||
|
1
app/views/authors/index.js.erb
Normal file
1
app/views/authors/index.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$("#items").html("<%= escape_javascript(render('authors/index')) %>");
|
12
app/views/books/_index.html.erb
Normal file
12
app/views/books/_index.html.erb
Normal 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 %>
|
||||||
|
|
@ -1,14 +1,2 @@
|
|||||||
<h1>All books</h1>
|
<h1>All books</h1>
|
||||||
|
<%= render 'books/index' %>
|
||||||
<%= will_paginate %>
|
|
||||||
|
|
||||||
<ul class="books">
|
|
||||||
<% @books.each do |book| %>
|
|
||||||
<li>
|
|
||||||
<%= link_to book.title, book %>
|
|
||||||
</li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= will_paginate %>
|
|
||||||
|
|
||||||
|
1
app/views/books/index.js.erb
Normal file
1
app/views/books/index.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$("#items").html("<%= escape_javascript(render('books/index')) %>");
|
9
app/views/series/_index.html.erb
Normal file
9
app/views/series/_index.html.erb
Normal 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 %>
|
@ -1,11 +1,2 @@
|
|||||||
<h1>Series</h1>
|
<h1>Series</h1>
|
||||||
|
<%= render 'series/index' %>
|
||||||
<%= will_paginate %>
|
|
||||||
|
|
||||||
<ul class="series">
|
|
||||||
<% @series.each do |serie| %>
|
|
||||||
<li><%= link_to serie.name, serie %></li>
|
|
||||||
<% end %>
|
|
||||||
</ul>
|
|
||||||
|
|
||||||
<%= will_paginate %>
|
|
||||||
|
1
app/views/series/index.js.erb
Normal file
1
app/views/series/index.js.erb
Normal file
@ -0,0 +1 @@
|
|||||||
|
$("#items").html("<%= escape_javascript(render('series/index')) %>");
|
@ -3,8 +3,10 @@
|
|||||||
<h2>Browse <%= @books_count %> books</h2>
|
<h2>Browse <%= @books_count %> books</h2>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<%= link_to "Books", books_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" %>
|
<%= link_to "Authors", authors_path, class: "btn btn-lg btn-primary", remote: true %>
|
||||||
<%= link_to "Series", series_path, class: "btn btn-lg btn-primary" %>
|
<%= link_to "Series", series_path, class: "btn btn-lg btn-primary", remote: true %>
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="center container-fluid" id="items">
|
||||||
|
</div>
|
||||||
|
Loading…
Reference in New Issue
Block a user