P
P
patriot022016-01-09 04:45:34
MODX
patriot02, 2016-01-09 04:45:34

Make sorting by price using select in modx mFilter2?

I don’t understand how to sort using select for the price in ascending and descending order
using the tag
"<a>", everything is clear,
"<select>"I can’t catch up with it.
Here is an example through "a" (everything works)

<a href="#" data-sort="ms|price:desc">По цене, mse2_sort_desc</a>

<a href="#" data-sort="ms|price:asc" >По цене, mse2_sort_asc</a>

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
serenia1, 2019-07-24
@serenia1

You copy all this and everything will work, maybe of course it was answered too late) but it definitely works

<div>
          <select class="sorting_cat"  id="mse2_sort">
  		<option class="sort" data-sort="resource|pagetitle" value="asc">Название (А - Я)</option>
  		<option class="sort" data-sort="resource|pagetitle" value="desc">Название (Я - А)</option>
  		<option class="sort" data-sort="ms|price" value="asc">Цена (по возрастанию)</option>
  		<option class="sort" data-sort="ms|price" value="desc">Цена (по убыванию)</option>        
  	  </select>
</div>

// Сортировка по цене mfilter2
$(document).ready(function() {
  $(document).on('change', '#mse2_sort', function() {
      var selected = $(this).find('option:selected');
      var sort = selected.data('sort');
      sort += mse2Config.method_delimeter + selected.val();
      mse2Config.sort =  sort;
      mSearch2.submit();
  });
});
 // Сортировка по цене mfilter2

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question