Search/filter form for a collection


I’m new in Ember.js, so far, it’s being fun to learn so much different things than I’m used to.

So, what I need to do is a search, but it is to search in one resource type only. For example, I have this list of projects that I need to filter them by multiple fields. The search process is done in the back-end, I will access it thru an API.

My API endpoint looks like this:

  • /api/projects get all projects.
  • /api/projects?name=foobar get all projects that contains foobar in the name.
  • /api/projects?name=foobar& get all projects that contains foobar in the name and has as the user email.

I think you can get the idea.

My problem is, I can’t find a way to send this data from the form to the controller. I tried to find examples of this kind of problem, but no luck on that All the examples that I found is creating a model for the search and setting the model attributes as the search fields. This is not a option for me since the endpoint is just one and I have only one model called project.

Note: I’m using ember-data to get the data.

This project that I’m working on is open source, so you can checkout how things are so far:

Any help is very welcome! Thanks.

Query parameters? Query Parameters - Routing - Ember Guides

Yeah, I thought that as well. But query params are only available in recent canary builds of Ember and when I pull the last canary build 3 days ago, my entire application stopped working.

Well, I figured out how to get the form data in the controller without a model.

Turns out that I needed to define in the controller the fields that my form will have and use it in the form. After that was simple to just get this info with this.get('field_name').

I’m not sure if it’s missing in the docs or it is just this new guy lost around. :smiley:

Anyway, if you want to see how I implemented this search feature, you can checkout this PR, any suggestions are welcome. Thanks.