diff --git a/app/controllers/product_controller.rb b/app/controllers/product_controller.rb index b7227f5..9655a42 100644 --- a/app/controllers/product_controller.rb +++ b/app/controllers/product_controller.rb @@ -12,7 +12,11 @@ class ProductController < ShopController def show @product = Product.where('slug = ?', params[:id]).first raise_404(@product) - render layout: false + respond_to do |format| + format.html + format.js + end + end private diff --git a/app/views/product/partials/_products_thumbnails.html.erb b/app/views/product/partials/_products_thumbnails.html.erb index 24cc183..5b7a28c 100644 --- a/app/views/product/partials/_products_thumbnails.html.erb +++ b/app/views/product/partials/_products_thumbnails.html.erb @@ -9,20 +9,20 @@
<% if !product.images.blank? %> - <%= link_to(image_tag(product.cover_image.image.url(:large), style: 'margin: auto;vertical-align: middle;display: inline-block;'), {controller: :product, action: :show, id: product.slug}, 'data-toggle': 'modal', 'data-target': ".productQuickView", + <%= link_to(image_tag(product.cover_image.image.url(:large), style: 'margin: auto;vertical-align: middle;display: inline-block;'), {controller: :product, action: :show, id: product.slug}, remote: true, 'data-toggle': 'modal', 'data-target': ".productQuickView", style: 'line-height: 338px;') %> <% else %> - <%= link_to(image_tag('kaktus.png'), {controller: :product, action: :show, id: product.slug}, 'data-toggle': 'modal', 'data-target': ".productQuickView") %> + <%= link_to(image_tag('kaktus.png'), {controller: :product, action: :show, id: product.slug}, remote: true, 'data-toggle': 'modal', 'data-target': ".productQuickView") %> <% end %>
- <%= raw link_to(raw(''), {controller: :product, action: :show, id: product.slug}, class: 'icon', 'data-toggle': 'modal', 'data-target': ".productQuickView") %> + <%= raw link_to(raw(''), {controller: :product, action: :show, id: product.slug}, remote: true, class: 'icon', 'data-toggle': 'modal', 'data-target': ".productQuickView") %> Dodaj do koszyka
-
<%= link_to(product.name, {controller: :product, action: :show, id: product.slug}, 'data-toggle': 'modal', 'data-target': ".productQuickView") %>
+
<%= link_to(product.name, {controller: :product, action: :show, id: product.slug}, remote: true, 'data-toggle': 'modal', 'data-target': ".productQuickView") %>
PLN <%= '%.2f' % product.price %> diff --git a/app/views/product/partials/_show.html.erb b/app/views/product/partials/_show.html.erb new file mode 100644 index 0000000..de7fbd7 --- /dev/null +++ b/app/views/product/partials/_show.html.erb @@ -0,0 +1,97 @@ + + diff --git a/app/views/product/show.js.erb b/app/views/product/show.js.erb index e69de29..042e820 100644 --- a/app/views/product/show.js.erb +++ b/app/views/product/show.js.erb @@ -0,0 +1,2 @@ +$('.productQuickView').html("<%= j render '/product/partials/show' %>"); +$('.productQuickView').modal('show');