Posted By

davebowker on 08/28/10


Tagged

sort date search jquery


Versions (?)

Search sorting buttons


 / Published in: jQuery
 

If on do nothing. If on make off. If off make on. Alter external value and focus.

  1. var searchHiddenSort;
  2. $('.ukn-search-sort a').click(function(e) {
  3. if ($(this).hasClass('ukn-search-sort-selected')) { return false; }
  4. var text = $(this).text();
  5. e.preventDefault();
  6. $('.ukn-search-sort-date, .ukn-search-sort-relevance').removeClass('ukn-search-sort-selected');
  7. $(this).addClass('ukn-search-sort-selected').parents('fieldset').find('.ukn-search-box input').focus();
  8. $(".ukn-form-hidden-search-sort").val(text);
  9.  
  10. if(searchHiddenSort) return;
  11. searchHiddenSort = true;
  12. $('.ukn-search fieldset').prepend('<input class="ukn-form-hidden-search-sort" type="hidden" name="sort" value=' + text + ' />');
  13. });

Report this snippet  

You need to login to post a comment.