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:
@@ -29,10 +29,8 @@
|
||||
% endif
|
||||
</p>
|
||||
|
||||
<div class="equation">
|
||||
|
||||
<div id="input_${id}_preview" class="equation">
|
||||
</div>
|
||||
|
||||
|
||||
<p id="answer_${id}" class="answer"></p>
|
||||
|
||||
|
||||
@@ -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));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user