Semantic-Org / Semantic-UI

Semantic is a UI component framework based around useful principles from natural language.
http://www.semantic-ui.com
MIT License
51.12k stars 4.94k forks source link

[Dropdown] How to use custom search function? #6164

Open ceremcem opened 6 years ago

ceremcem commented 6 years ago

I need to use custom search function with dropdown. Currently editing dropdown.js like the following provides a workaround:

        filterItems: function(query) {
          var
            searchTerm = (query !== undefined)
              ? query
              : module.get.query(),
            results          =  null,
            escapedTerm      = module.escape.string(searchTerm),
            beginsWithRegExp = new RegExp('^' + escapedTerm, 'igm')
          ;
          // avoid loop if we're matching nothing
+          if (typeof settings.fullTextSearch === 'function') {
+            settings.fullTextSearch(searchTerm);
+          }
+          else if( module.has.query() ) {
-          if( module.has.query() ) {

Now when I type something into the search box of the dropdown, the fullTextSearch(searchTerm) function is run. I set the filtered data in this handler and refill the dropdown content accordingly.

Is there any proper way to use a custom search function?

stale[bot] commented 6 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 30 days if no further activity occurs. Thank you for your contributions.