Domanda

I am new to ember and I have a question about the models.

I got a "key":["value1, "value2] list in a json-file. The keys and the values are arbitrary and I want to hold that list in the (DS.)store. To use it for an autocomplete and some other stuff.

Is there a sophisticated way to create a model from a json file, including the keys? All the examples I have found until now it was always a predefined key and a arbitrary value. Of course I can iterate over the keys first but is there a nicer way?

The purpose is to create an auto-complete application which suggests the user first the keys and when a key is selected the possible values. But when the user starts searching he will get a new keyword file and the auto-complete function shall be updated with that new data.

My auto-complete is based on this tutorial http://www.embercasts.com/episodes/building-an-autocomplete-widget-part-1

Thanks for your help, I hope it's not the dumbest question ever^^ If you know nice tutorials or stuff I would appreciate links too:)

È stato utile?

Soluzione

Not sure I completely understand the question, but you can load arbitrary payloads into the the data store by calling pushPayload

var pushData = {
  autocompleteObjects: [
    {id: 1, value1: "foo", value2: "bar"}
  ]
}    
store.pushPayload('autocompleteObject', pushData)

Maybe in your app you could get for the JSON file and push the payload?

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top