Developers

Categories Dropdown

Overview

This component is a dropdown selector for categories.

There are two ways to use it:

  • You can use it on its own and listen to its events to update the view, or
  • You can link it to the categories component. Doing this either updates this component when a category is clicked in the categories component, or updates the categories component when this component has values selected.

Usage

Create the component like this:

var categoriesDropdown = sdk.component('categoriesDropdown', target:String, options:Object);

Sample

By default, this component looks like this:

Target

This is the HTML component. For example, the "#inbenta" target is:

<div id="inbenta"></div>

Options

Available options to set in this component

Name Type Default Description
selectedCategory integer 0 Active category
baseCategory integer 0 Starting point of the category tree

Default options object

{
  selectedCategory: 0,
  baseCategory: 0
}

Methods

The following methods can be used in this component:

Name Description
setSelectedCategory(category: integer) Set the active category
setBaseCategory(category: integer) Set the base category

Subcomponents

This component does not have any subcomponents.

Events

Events to listen on this component:

Name Event data Description
categoryId integer Active category

Tracking

This component does not track any data.

Labels

Labels of this component. The default labels of each component can be rewritten in the SDK creation configuration.

Name Default Description
CATEGORIES_DROPDOWN_TITLE Categories HTML for categories sidebar title
CATEGORIES_DROPDOWN_PLACEHOLDER Choose category HTML for categories dropdown placeholder

Examples

Create sidebar and categories components and link them.

var categoriesDropdown = sdk.component('categoriesDropdown', '#sidebar');
var categories = sdk.component('categories', '#categories');
categories.linkToCategoriesDropdown(categoriesDropdown);