gitana / alpaca

Alpaca provides the easiest way to generate interactive HTML5 forms for web and mobile applications. It uses JSON Schema and simple Handlebars templates to generate great looking, dynamic user interfaces on top of Twitter Bootstrap, jQuery UI, jQuery Mobile and HTML5.
http://www.alpacajs.org
Other
1.29k stars 371 forks source link

Issue with radio field data source inside array #647

Open pinnama1212 opened 6 years ago

pinnama1212 commented 6 years ago

Hi, I have a scenario, where i display multiple questions and answers. Answers are radio buttons. But this radio items comes from a function so i have user dataSource. But there is a recursion call happening to this dataSource function. I have created an example in jsfiddle https://jsfiddle.net/pinnama/w5b6z8df/55/. Can you please correct me if i am missing some thing?

WhileTrueEndWhile commented 6 years ago

Your runtime manipulations do not seem to influence "Selection"... Please check the Alpaca version. If you are using version 1.5.24, it might work with version 1.5.23. But it doesn't have to be.

pinnama1212 commented 6 years ago

Thank you, i will try and post my comments today.

pinnama1212 commented 6 years ago

I tried with 1.5.23 but behavior is same. Seems like an endless loop for binding data in this case. Can someone help me real quick as I got stuck with this and we are having a demo this weekend.

ambischof commented 6 years ago

Are you trying to build a form where both the questions and the options are fed from a function? I am assuming that the data attribute you specified is how you are receiving the questions.

Assuming this is correct, you are setting up the form backwards. The data attribute is meant to populate the form answers, not the questions. The schema and options for the form should be written after you already know what the questions are, so create a function which takes those specifications and creates the schema and options.

ambischof commented 6 years ago

Here's something I threw together which I think is what you're trying to do. https://jsfiddle.net/w5b6z8df/83/

I didn't do everything, like address the difference between the different QuestionType like multiselect and choice, but this should get you started.