1.0.5 • Published 3 years ago

flourish-search-ui v1.0.5

Weekly downloads
-
License
UNLICENSED
Repository
-
Last release
3 years ago

Flourish search ui

to initialise

import search from "flourish-search-ui"

var search = initSearch(state.search)

Methods

drawTo

this should be passed the parent element you wish to append the search bar to. It triggers the draw function inside the module.

search
		.drawTo(layout.getSection("primary"))

dataHasChanged

this should be passed a boolean and tells the module when to redefine the search function.

layout

this should be passed the layout of the template and is used to proivde the search bar with back up colors for background and font.

searchableData

this is the data you want to the search bar to search through.

onType

this should be passed the function (if any) that you want to be triggered when typing. it is given the search results as an array. If the dropdown is turned off then this is the only place you will be able to write functionality for what happens on search.

		.onType(function (search_results) {
	        // do something with search results if you want
		})

dataValueAccessor

this takes a function such as:

		.dataValueAccessor(function(d) { return d.source + "-" + d.index; })

it is the accessor used to determine the data-value of each item in the dropdown, and is what is passed to the onSelectFromDropdown function when you select an item in the dropdown.

onSelectFromDropdown

this is triggered when you select an item from the dropdown, it should be passed a function that takes a data-value (which is determined by the dataValueAccessor passed in above)

update

triggers the update!