Advertisement
Guest User

Untitled

a guest
Jan 16th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. class Categorization < ApplicationRecord
  2. belongs_to :category
  3. belongs_to :provider
  4. end
  5.  
  6. class Category < ApplicationRecord
  7. has_many :categorizations
  8. has_many :providers, through: :categorizations
  9. accepts_nested_attributes_for :categorizations
  10. end
  11.  
  12. class Provider < ApplicationRecord
  13. has_many :categorizations
  14. has_many :categories, through: :categorizations
  15. accepts_nested_attributes_for :categorizations
  16. end
  17.  
  18. <ul class="nav nav-justified nav-carousel upper-thumbs">
  19. <% Provider.order(created_at: :asc).take(6).each_with_index do |provider, index| %>
  20. <li id="<%= provider.name %>_<%= index + 1 %>" class="btn-up"><a data-href="#"><%= provider.name %></a></li>
  21. <% end %>
  22. </ul>
  23.  
  24. <ul id="parent" class="nav nav-justified nav-carousel left-thumbs">
  25. <% Category.order(created_at: :asc).take(7).each_with_index do |category, index| %>
  26. <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>
  27. <% end %>
  28. </ul>
  29.  
  30. var $btns = $('.btn-up').click(function () {
  31. if(this.id == 'a') {
  32. $('#parent > li#aside_1').fadeIn(450);
  33. $('#parent > li').not($('#parent > li#aside_1')).hide();
  34. } else {
  35. var $el = $('.' + this.id).fadeIn(450);
  36. $('#parent > li').not($el).hide();
  37. }
  38. $btns.removeClass('active');
  39. $(this).addClass('active');
  40. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement