【发布时间】:2013-08-20 09:23:38
【问题描述】:
大家好,我正在使用 django-tastypie 进行问答。
在我的模板中,需要打印与某个主题相关的所有问题以及与特定问题相关的所有答案,为此我将一个对象传递给 jQuery 文件并在那里迭代该对象。
这是代码
$(data.quiztopics).each(function(index,element){
$(element.questions).each(function(index,question){
$(".quiz").append("<table id='question_"+question.id+">"+
"<tr><p name='question' id=question_"+question.id+">"+
(question.question_text) +
"</p></tr><tr id=answer_"+question.id+"></tr>");
$(question.answers).each(function(index,answer){
$("#answer_"+question.id).append("<td>"+
"<input type='radio' name='answer'id=answer_"+answer.id+">"+
answer.answer_text +
"</input></td>");
});
在 console.log 中,它显示一切正常,即与特定问题相关的答案。 bt 当我将它附加到表格行时,它错过了一些问题的答案 即
10+10
120 20 30 1
10*10
100 00 20 1
10/10
10-10
请告诉我解决方案我怎样才能将所有答案放在相关问题下
【问题讨论】:
标签: javascript jquery tastypie