Commit 15d4af26 by Victor Shnayder

Merge pull request #899 from MITx/feature/victor/capa-ajax

Make chem preview more robust
parents 97233cf0 f4d8df94
...@@ -29,11 +29,9 @@ ...@@ -29,11 +29,9 @@
% endif % endif
</p> </p>
<div class="equation"> <div id="input_${id}_preview" class="equation">
</div> </div>
<p id="answer_${id}" class="answer"></p> <p id="answer_${id}" class="answer"></p>
% if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']: % if status in ['unsubmitted', 'correct', 'incorrect', 'incomplete']:
......
(function () { (function () {
update = function() { update = function() {
preview_div = $(this).siblings('div.equation');
function create_handler(saved_div) { function create_handler(saved_div) {
return (function(response) { return (function(response) {
if (response.error) { if (response.error) {
...@@ -12,6 +10,9 @@ ...@@ -12,6 +10,9 @@
}); });
} }
prev_id = "#" + this.id + "_preview";
preview_div = $(prev_id)
$.get("/preview/chemcalc/", {"formula" : this.value}, create_handler(preview_div)); $.get("/preview/chemcalc/", {"formula" : this.value}, create_handler(preview_div));
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment