Guest User

Untitled

a guest
Oct 20th, 2017
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | None | 0 0
  1. %header
  2. %h1.grid_2
  3. = link_to 'Prizzm'
  4. = form_tag '', :class => "grid_6" do
  5. = text_field_tag :search, nil, :class => "jq_watermark grid_6", :id => "product-search-input", :title => "Keywords, Tags, Items, SKU..."
  6. = submit_tag "ADD NEW ITEM"
  7. - if signed_in?
  8. %nav.grid_4
  9. %ul
  10. %li= link_to 'Dashboard', home_url, :class => "active"
  11. %li= link_to 'Browse'
  12.  
  13. %script(type="text/html" id="product-autocomplete-result-template")
  14. .cell.img
  15. %img(src='{{ main_image_thumb }}')
  16. .cell
  17. %h2= link_to '{{ label }}', CGI::unescape(product_path('{{ id }}'))
  18. .clear
  19. = link_to '{{ customer_count }} people have this', '#'
  20. Rating {{ rating }}
  21. %div{:id => "stars-wrapper-{{ id }}"}
  22. %select= options_for_select([1, 2, 3, 4, 5])
  23.  
  24. .cell
  25. = link_to "I have this", '#', :class => "button"
  26. = link_to "I want this", '#', :class => "button"
  27.  
  28. :javascript
  29. $(document).ready(function(){
  30. $('#product-search-input').autocomplete({
  31. delay: 50,
  32. source: "#{search_products_path}",
  33. select: function(event, ui){
  34. //store selected.object_id to hidden field value
  35. var product_id = ui.item.id;
  36. $('#item_product_id').val(product_id);
  37. }
  38. })
  39. .data( "autocomplete" )._renderItem = function( ul, item ) {
  40. var template = $('#product-autocomplete-result-template').html();
  41. var parsed_template = _.template(template, item);
  42. var target_option = 'value="' + item.rating + '"'; // do simple string replace to select option, as I can't get Jquery
  43. var selected_option = target_option + ' selected="selected"';
  44. var autocomplete_html = parsed_template.replace(target_option, selected_option);
  45. var returnVal = $( "<li class="row"></li>" )
  46. .data( "item.autocomplete", item )
  47. .append(autocomplete_html)
  48. .appendTo( ul );
  49. $("#stars-wrapper-"+item.id).stars({ inputType: "select", disabled: true });
  50. return returnVal;
  51. };
  52. });
Add Comment
Please, Sign In to add comment