$.ajax({
url: "/survey/surveyQuestions",
success: function (questionsData) {
$.ajax({
url: "/survey/surveyOptions",
success: function (optionsData) {
alert(questionsData.length);
for (var i = 0; i < questionsData.length; i++) {
QuestionsScript.Question = ko.mapping.fromJS(questionsData[i]);
ko.applyBindings(QuestionsScript, document.getElementById("innerDiv"));
for (var j = 0; j < optionsData.length; j++) {
if (optionsData[j].QuestionId = questionsData.QuestionId[i]) {
OptionsScript.Option = ko.mapping.fromJS(optionsData[j]);
ko.applyBindings(OptionsScript, document.getElementById(" ... here i nee to give options template table Id....."));
}
}
}
}
});
}
});
I need to bind like below
Question 1
Option1
Option2
Option3
Question 2
Option1
Option2
Option3
Question 3
Option2
Option3
My Templates are
<script id="QuestionsScript" type="text/x-jquery-tmpl">
<div data-bind="attr:{id :QuestionId}" class="question">
<h2><label data-bind="text :QuestionText" /></h2>
<div class="option">
<table data-bind="attr:{id : QuestionId} , template: {name:'OptionsScript', foreach: Option}">
<tbody>
</tbody>
</table>
</div>
</div>
</script>
<script id="OptionsScript" type="text/x-jquery-tmpl">
<tr>
<td>{{= OptionText}}</td>
</tr>
</script>
As I have stated about my desired output and template,I am not aware why I can't get that. so Kindly provide me with any sample code for this. Thanks in advance.