Select Dropdown Text On URL Change


#1

I am using the ui dropdown to stylize a select which is used for sort. The sort functions well but upon URL change the selected item within the dropdown is refreshed to the default. How can I make it so that it preserves the last selected on url change.

  <div id="collectionSort">
      <select class="ui dropdown" id="selectSort" onchange='window.location="{{ collection.url }}?sort_by=" + this.value'>

        <option value="price-ascending">Price (lowest first)</option>
        <option value="price-descending">Price (Highest first)</option>
        <option value="title-ascending">A-Z</option>
        <option value="title-descending">Z-A</option>
        <option value="created-descending">Latest Addition</option>
      </select>
</div>

#2

you´ve use javascript api like

$(".ui.dropddown").dropdown({
onChange: function(value, text, $selectedItem) {
// custom action
}
})

because javascript module change your html to

Gender
Male
Female