Skip to content

Sorting

dbuthay edited this page Aug 12, 2011 · 1 revision

Requirements

  • an Indextank_[Ize]'d FORM.
  • an Indextank_[AjaxSearch]'d INPUT to listen to.
  • import jquery.indextank.sorting.js

How it works

Sorting binds to an element to display sorting controls for the results of an AjaxSearch. It allows to re-run the last query with a modified scoringFunction, when a label is clicked.

Usage

var s = $("#sorting").indextank_Sorting({labels: {"relevance": 0, "newest": "1"}});
$("#query").indextank_AjaxSearch({listeners: s});

Options

  • labels: an Object with function names as keys and integers as values. In the example above, relevance is the function 0, and newest is the function 1. Make sure the names match the semantics for the functions defined for your index.

Events

  • Reacts to

    • Indextank.AjaxSearch.success: Keeps track of the latest query, to re-run it with a modified scoringFunction if needed.
  • Triggers

    • Indextank.AjaxSearch.runQuery: When a label is clicked, it clones the last query, changes the scoringFunction and re-runs it.

Clone this wiki locally