Make chem preview more robust

- give the preview div an id, use that to look it up instead of dancing around in the DOM
This commit is contained in:
Victor Shnayder
2012-10-14 11:35:32 -04:00
parent db8639e06a
commit f4d8df94dd
2 changed files with 4 additions and 5 deletions

View File

@@ -29,10 +29,8 @@
% endif
</p>
<div class="equation">
<div id="input_${id}_preview" class="equation">
</div>
<p id="answer_${id}" class="answer"></p>

View File

@@ -1,7 +1,5 @@
(function () {
update = function() {
preview_div = $(this).siblings('div.equation');
function create_handler(saved_div) {
return (function(response) {
if (response.error) {
@@ -12,6 +10,9 @@
});
}
prev_id = "#" + this.id + "_preview";
preview_div = $(prev_id)
$.get("/preview/chemcalc/", {"formula" : this.value}, create_handler(preview_div));
}