Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Switch to Materialize plugin for sortBySelector #8

Closed
chadokruse opened this issue Oct 18, 2017 · 1 comment
Closed

Switch to Materialize plugin for sortBySelector #8

chadokruse opened this issue Oct 18, 2017 · 1 comment

Comments

@chadokruse
Copy link
Owner

chadokruse commented Oct 18, 2017

Currently we do not use Materialize styling for the sortBySelector widget as the Materialize widget needs to be initialized AFTER the element is rendered by Instantsearch.

As a interim hack, we simply adjust the styling of the select element and do not use the Materialize select plugin.

The TODO is to figure out how best to initialize the Materialize plugin in the normal Instantsearch flow.

Other widgets have the templates API which can take a function, but the sortBySelector does not.

Adding a full custom widget seems unnecessary, though as of last November it was the recommended method.

Instantsearch does provide the render method, but haven't yet figured out how to implement.

Have attempted initializing via a partial custom widget, but that simply renders another widget which has no interactivity with Instantsearch.

search.addWidget({
    render: function(options) {
      $('select').material_select();
    }
  });

Have also tried forcing init into the normal Instantsearch addWidget workflow:

search.addWidget(
    {
      init: function(options) {
        $('select').material_select();
      }
    },
    instantsearch.widgets.sortBySelector({
      container: '#ais-widget-sort-by',
      cssClasses: {
        root: 'input-field'
      },
      indices: [
        {name: 'demo', label: 'Most relevant'},
        {name: 'demo_amount_desc', label: 'Grant size'},
      ]
    })
  );
@chadokruse
Copy link
Owner Author

Recommended approach is indeed a custom widget via connectSortBySelector.

De-prioritizing this todo as the existing implementation 'works', though a bit hacky

@chadokruse chadokruse removed the to do label Oct 19, 2017
@chadokruse chadokruse changed the title Switch to Materialize plugin for sortyBySelector Switch to Materialize plugin for sortBySelector Oct 19, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant