Commit 5293de9484ebcbd06058898114463efb0b75760d
1 parent
35b00cd4
Exists in
master
and in
22 other branches
[search-improvements] Realize search through ajax and update only results
Missing update through ajax on sorting
Showing
10 changed files
with
41 additions
and
4 deletions
Show diff stats
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +jQuery('#search-content').html('<%= escape_javascript(render :partial => "search_content") %>'); | ... | ... |
app/views/search/search_page.html.erb
| ... | ... | @@ -3,10 +3,7 @@ |
| 3 | 3 | <%= render :partial => 'search_form', :locals => { :hint => _("Type words about the %s you're looking for") % @asset.to_s.singularize } %> |
| 4 | 4 | <%= render :partial => 'results_header' %> |
| 5 | 5 | |
| 6 | -<%= display_results(@searches, @asset) %> | |
| 7 | -<% if params[:display] != 'map' %> | |
| 8 | - <%= pagination_links @searches[@asset][:results] %> | |
| 9 | -<% end %> | |
| 6 | +<%= render :partial => 'search_content' %> | |
| 10 | 7 | |
| 11 | 8 | <div style="clear: both"></div> |
| 12 | 9 | |
| ... | ... | @@ -15,3 +12,5 @@ |
| 15 | 12 | jQuery('.search-product-price-details').altBeautify(); |
| 16 | 13 | <% end %> |
| 17 | 14 | <% end %> |
| 15 | + | |
| 16 | +<%= javascript_include_tag 'search' %> | ... | ... |
| ... | ... | @@ -0,0 +1,22 @@ |
| 1 | +(function($) { | |
| 2 | + //TODO Sorting | |
| 3 | + // Sorting and pagination links. | |
| 4 | + $('#search-content .pagination a').live('click', | |
| 5 | + function () { | |
| 6 | + $.getScript(this.href); | |
| 7 | + return false; | |
| 8 | + } | |
| 9 | + ); | |
| 10 | + | |
| 11 | + // Search form | |
| 12 | + $('form.search_form').submit(function () { | |
| 13 | + $.ajax({ | |
| 14 | + url: this.action, | |
| 15 | + data: $(this).serialize(), | |
| 16 | + beforeSend: function(){$('#search-content').addClass('searching')}, | |
| 17 | + complete: function() {$('#search-content').removeClass('searching')}, | |
| 18 | + dataType: 'script' | |
| 19 | + }) | |
| 20 | + return false; | |
| 21 | + }); | |
| 22 | +})(jQuery); | ... | ... |
public/stylesheets/application.css