What picking a result does
What picking a result does
By default, picking a passage opens the reader where the results were. To do something else, such as opening your own page for reading, give onSelect:
ScriptureTips.search({
element: "#find",
onSelect({ result }) {
location.href = "/read/" + result.translation.id + "/" + result.reference;
},
});
It is given { query, result }. The result's label is the passage as it reads in its translation (John 3:16), reference is the same in OSIS (John.3.16), and translation is its id and abbreviation. A word in the original language has a strong number instead. A function that does nothing turns the reader off.
Listening without taking over
Every search also sends events your page can listen to: st-select, st-results, st-error on its elements.
document.addEventListener("st-select", (e) => console.log(e.detail));