Improves answer reloading.
authorFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 24 Jan 2011 21:10:24 +0000 (22:10 +0100)
committerFlorent Bruneau <florent.bruneau@polytechnique.org>
Mon, 24 Jan 2011 21:10:24 +0000 (22:10 +0100)
Signed-off-by: Florent Bruneau <florent.bruneau@polytechnique.org>
htdocs/javascript/survey.js
templates/survey/edit.questions.tpl

index 17ffcb7..7823baa 100644 (file)
                 q = { qid: id };
             }
             var question = $("#q_edit_new").tmpl(q);
-            question
+            var type = question
                 .children('select[name$="[type]"]')
                 .change(function () {
                     var type = $(this).val();
                     }
                     return true;
                 });
+            if (type.val()) {
+                question.children('.q_edit_form')
+                        .bindQuestion(type.val(), q.qid);
+            }
             this.childrenContainer().children('.add_question').before(question);
             $.renumberQuestions();
             return question;
                             type: $(this).val(),
                             disabled: "disabled"
                         }));
-                });
+                })
+                .change();
             return this;
         },
 
             var question = this.question();
             var answer = $("#q_edit_multiple_answer").tmpl({ qid: question.qid() });
             question.childrenContainer().children('.add_answer').after(answer);
+            question.multiple_selectSubtype().change();
             return answer;
         }
     });
index 393ebc4..5559ebf 100644 (file)
@@ -97,8 +97,7 @@
 
 <script id="q_edit_multiple_answer" type="text/x-jquery-tmpl">
   <div>
-    <span class="q_edit_answer_box">
-    </span>
+    <span class="q_edit_answer_box"></span>
     RĂ©ponse&nbsp;: <input type="text" name="q_edit[${qid}][answer][][value]" value="${value}" />
   </div>
 </script>