question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

[indexSelector] create widget

See original GitHub issue

This widget needs to be able to render this:

2015-08-05-102322_312x86_scrot

API

Given this html:

<div id="sort-results"></div>

And JavaScript:

instant.addWidget(
  instant.widgets.indexSelector({
    container : "#sort-results",
    indices: [{
      name: 'index', label: 'Relevance'
    }, {
      name: 'index_priceASC', label: 'Highest price'
    }, {
      name: 'index_priceDESC', label: 'Lowest price'
    }]
  })
);

We render:

<select>
  <option value="index">Relevance</option>
  <option value="index_priceASC">Highest price</option>
  <option value="index_priceDESC">Lowest price</option>
</select>

Options

  • container string or DOMElement
  • indices array of objects
  • cssClass string (comma separated list of css classes to apply to root element)

Behavior

The selected index is the one set in the helper as the current one.

If the selected index is not one from the list, then we should throw an error.

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:14 (14 by maintainers)

github_iconTop GitHub Comments

1reaction
vvocommented, Aug 6, 2015

To provide a higher level of customization for this widget, we should enhance it.

So that people could pass their own template (so that they can use bootstrap dropdown components for example).

For this, we only need to provide an API to the instantiated widget, something like:

var selector =   instant.widgets.indexSelector({
  container : "#sort-results",
  indices: [{
    name: 'index', label: 'Relevance'
  }, {
    name: 'index_priceASC', label: 'Highest price'
  }, {
    name: 'index_priceDESC', label: 'Lowest price'
  }],
  template: 'Your template, you will receive an array of indices and one of them will have the `selected` property set'
});

selector.changeIndex('index_priceASC');

But I do not know how it will play with react and how to bind the events in it. Maybe that’s not the good way to do it.

For people wishing to use complex switch widgets like bootstrap widgets we should put this in userland (= do the widget ourselves in another repo, or let the community do it).

If you agree with this I will open another issue with this enhancement.

0reactions
pixelasticcommented, Sep 4, 2015

Do we have use-cases where an implementation uses this kind of widget for something else than sort order?

Read more comments on GitHub >

github_iconTop Results From Across the Web

jupyter-widgets/Lobby
I have used pyplot to create a figure with a legend. By default, the legend is framed. So my question is: how do...
Read more >
Selectors
IndexSelector selects the elements closest to an abcissa; LassoSelector selects elements in a region drawn by the user. How they work. bqplot Selectors...
Read more >
Add widget from python to a specific widget depth.
In your python file, you just need to import and create an ObjectProperty to reference the widget. #With your other imports
Read more >
Use a Custom Widget as a Selector
When an out-of-the-box MicroStrategy widget is added to a document, it can be used as a selector that targets other controls in the...
Read more >
instantsearch.js
instantsearch.js is a library of widgets to build high performance ... searchBox; stats; indexSelector; hitsPerPageSelector; pagination ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found