Alpaca framework select with multiple:true inherits the selection status of its former siblings

265 views Asked by At

This issue original raise on github of alpaca framework, https://github.com/gitana/alpaca/issues/731 Just open one here for getting support from stackoverflow community.

A Combination of multi select and array cause a problem that the second and later select boxes inherit the selection status of their former siblings.
See my codepen: https://codepen.io/hadakadenkyu/full/pooKyzy

any help would be appreciated!!

1

There are 1 answers

0
Oussama BEN MAHMOUD On BEST ANSWER

Your issue was related to the object datasource that you've created. Internally alpacajs transforms your datasource object to text and value, and it needs it to be only of type {key: value} so in your example you should do {"2001": 2002} for example.

Moreover, in your alpaca form data object you should use select option values not text like: year: ["2001", "2003"]

Update: I rechecked the documentation and I saw:

Datasource for generating list of options. This can be a string or a function. If a string, it is considered S be a URI to a service that produces a object containing key/value pairs or an array of elements of structure {'text': '', 'value': ''}. This can also be a function that is called to produce the same list.

So to make your example works you should wrap your datasource object value into a function like:

dataSource: function(callback) {
                callback([
                  { "text": "2000", "value": 2000 }, ...

Here's the first example.

Here's the second example.