The QueryStateModel is a key->value store of the state of every component that can affect a query.
Component set values in this key -> value store, and listen to event triggered to react accordingly.
For example, when a query is launched, the searchbox will set the 'q' attribute, the pager will set the 'first' attribute, etc.
At the same time, this class will trigger the associated event when a value is modified.
eg : The user change the content of the searchbox, and submit a query. This will trigger the following events :
-- state:change:q (because the value of 'q' changed) -- state:change (because at least one value changed in the query state)
Component or external code could hook handler on those events : document.addEventListener('state:change:q', handler);
See : Model, as all the relevant method are exposed in the base class.
Optionally, the state can be persisted to the query string to allow browser history management : See HistoryController
Determine if at least one facet is currently active in the interface (this means that a facet has selected or excluded values)
Return the debug info about this component.
Disable the component. Normally this means that the component will not execute handlers for the framework events (query events, for example). Component are enabled by default on creation.
Enable the component. Normally this means that the component will execute handlers for the framework events (query events, for example). Components are enabled by default on creation.
Gets the value of a single specific attribute. If no attribute is specified, the method instead returns an object containing all registered attribute key-values.
the specific attribute whose value should be returned.
Gets an object containing all active registered attribute key-values. An attribute is considered active when its value is not in its default state.
Gets the default value of a single specific attribute. If no attribute is specified, the method instead returns an object containing all registered attribute key-default values.
the specific attribute whose default value should be returned.
Gets a string displaying the event namespace followed by the specific event name. The returned string is formatted thus:
the event name.
Registers a new attribute key-value.
the name of the new attribute to register.
the newly registered attribute default value.
Resets each registered attribute to its default value.
Note: this method calls the setMultiple method without specifying any options.
setMultiple call has returned, this method triggers the
Sets the value of a single specific attribute.
Note: this method calls the
the specific attribute whose value is to be set.
the value to set the attribute to.
the options (see setMultiple).
Sets a single specific attribute to its default value. Note: this method calls the setMultiple method without specifying any option.
the specific attribute whose value is to be set to its default value.
Sets the values of one or many attributes.
This method may trigger the following events (in order):
the key-value list of attributes with their new intended values.
customAttribute option is set to
true, the method will not validate whether an attribute is registered or not.
validateType option is set to
true, the method will ensure that each value type is correct.
silent option is set to
true, then the
all events will not be triggered.
Sets a new default value to a single specific attribute. Note: specifying a new attribute default value does not set the attribute to that value. This can be done using the setDefault method.
the specific attribute whose default value is to be changed.
the new intended default value.
customAttribute option is set to
true, the method will not validate whether the attribute is registered or not.
The attributes contained in this model. Normally, you should not set attributes directly on this property, as this would prevent required events from being triggered.
A disabled component will not participate in the query, or listen to ComponentEvents.
Allows component to log in the dev console.
The static ID that each component need to be identified.
For example, SearchButton -> static ID : SearchButton -> className : CoveoSearchButton
The event types that can be triggered:
preprocess: triggered before a value is set on an attribute. This allows the value to be modified before it is set.
changeOne: triggered when a single value changes.
change: triggered when one or many values change.
reset: triggered when all attributes are reset to their default values.
all: triggered after the