Guest User

Untitled

a guest
Jul 17th, 2018
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.00 KB | None | 0 0
  1. function replaceDropDowns() {
  2. jQuery('.product_attribute_option_link').remove();
  3. jQuery('#selected_combination').text('');
  4. jQuery(".super-attribute-select").each(function() {
  5. var drop_down = jQuery(this);
  6. drop_down.hide();
  7. drop_down.find("option[value!='']").each(function() {
  8. var option = jQuery(this);
  9. jQuery("<a>", {
  10. text: option.text(),
  11. href: '#',
  12. class: 'product_attribute_option_link',
  13. 'data-id': drop_down.attr('id'),
  14. 'data-name': drop_down.attr('name'),
  15. 'data-value': option.val(),
  16. 'data-label': option.text(),
  17. click: function() {
  18. drop_down.val(option.val());
  19. var obj = drop_down.get();
  20. Event.observe(obj[0],'change',function(){});
  21. fireEvent(obj[0],'change');
  22. replaceDropDowns();
  23. var selected_combination = [];
  24. jQuery(".super-attribute-select").each(function() {
  25. if(jQuery(this).val()) {
  26. jQuery(".product_attribute_option_link[data-value="+jQuery(this).val()+"]").addClass('product_attribute_option_link_selected');
  27. selected_combination.push(jQuery(this).find("option:selected").text());
  28. }
  29. });
  30. jQuery.each(selected_combination, function(index, selection) {
  31. jQuery('#selected_combination').append(selection);
  32. if(index+1 < selected_combination.length)
  33. jQuery('#selected_combination').append(" - ");
  34. })
  35. return false;
  36. }
  37. }).appendTo(drop_down.parent());
  38. })
  39. });
  40. }
  41.  
  42. jQuery(function() {
  43. replaceDropDowns();
  44. });
Add Comment
Please, Sign In to add comment