Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Categorization < ApplicationRecord
- belongs_to :category
- belongs_to :provider
- end
- class Category < ApplicationRecord
- has_many :categorizations
- has_many :providers, through: :categorizations
- accepts_nested_attributes_for :categorizations
- end
- class Provider < ApplicationRecord
- has_many :categorizations
- has_many :categories, through: :categorizations
- accepts_nested_attributes_for :categorizations
- end
- <ul class="nav nav-justified nav-carousel upper-thumbs">
- <% Provider.order(created_at: :asc).take(6).each_with_index do |provider, index| %>
- <li id="<%= provider.name %>_<%= index + 1 %>" class="btn-up"><a data-href="#"><%= provider.name %></a></li>
- <% end %>
- </ul>
- <ul id="parent" class="nav nav-justified nav-carousel left-thumbs">
- <% Category.order(created_at: :asc).take(7).each_with_index do |category, index| %>
- <li id="aside_<%= index + 1 %>" class="btn-aside"><i class="category_image" style="background: url(<%= category.cat_image %>) no-repeat;"></i><a data-href="#"><%= category.name %></a></li>
- <% end %>
- </ul>
- var $btns = $('.btn-up').click(function () {
- if(this.id == 'a') {
- $('#parent > li#aside_1').fadeIn(450);
- $('#parent > li').not($('#parent > li#aside_1')).hide();
- } else {
- var $el = $('.' + this.id).fadeIn(450);
- $('#parent > li').not($el).hide();
- }
- $btns.removeClass('active');
- $(this).addClass('active');
- })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement