Getting values from inputs, then building a URL fragment from them


#1

I need some help getting this to work. What I’m attempting to do is allow the user to input some value into an input box, choose to add new boxes, input some more values and then submit them. At which point I want to grab each value and build out a URL that looks something like this…

“&allowedIngredient[]=beef&allowedIngredient[]=chees&allowedIngredient[]=eggs”

Here is the code I’m trying to work with right now. Not sure if I’m even getting close to the proper way to do this.

App.Keys = Ember.A();

App.Recipes = Ember.Object.extend({
  keywords: function(){
      App.Keys.map(function(key){return '&allowedIngredient[]='+key+''});
  }
});

App.IndexRoute = Ember.Route.extend({
    actions: {
        search: function(){
            $('input[name=keyword]').each(function(){
                App.Keys.pushObject($(this).val());
            });
            alert(App.Recipes.keywords);
        }
     }
});

After this has been done I will eventually use it to build a URL that has an empty spot where Ember will insert this bit into and call so I get search results based on what I actually typed.