SpoonX/aurelia-autocomplete

How to override method searchQuery

Closed this issue · 6 comments

Hi, I'm trying to override the searchQuery method which i see according to the documentation is possible, but I can't figure out how. For now I just modified the autocomplete.js in the jspm folder AutoCompleteCustomElement.prototype.searchQuery function though I know it is a bad practice

There's no built in method to override the searchQuery method. You can, however, supply criteria. What's the change you'd like to make? Maybe I can give you an alternative approach.

Basically I don't want to use waterline queries, I just want a standard querystring like ?search=terms.
I'm using asp net web api 2 in the backend and looks like to do a querystring where[x][contains] with the [] as part of the parameter name would require me to do a lot of extra work without any gain. Thanks, lmk if you think of something!

Ah yeah, if that's your goal then this isn't ideal.

Maybe it's an idea to implement a configurable searchQuery method? Would you like to try that?

Yup! will give it a try and send PR in a few days with that.

@JamesReate Hey! Is this still an issue? Did you resolve it?

For other people that are wandering about this:

In your view add:

view-model.ref="autocomplete"

In your code add:

  bind() {
    this.autocomplete.searchQuery = search => {
      return '?search=' + search;
    };
  }