Search sorting buttons


/ Published in: jQuery
Save to your folder(s)

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


Copy this code and paste it in your HTML
  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


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.