From f4d8df94dde0c94106127fd539f34ca1b2bceeeb Mon Sep 17 00:00:00 2001 From: Victor Shnayder Date: Sun, 14 Oct 2012 11:35:32 -0400 Subject: [PATCH] Make chem preview more robust - give the preview div an id, use that to look it up instead of dancing around in the DOM --- common/lib/capa/capa/templates/chemicalequationinput.html | 4 +--- common/static/js/capa/chemical_equation_preview.js | 5 +++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/common/lib/capa/capa/templates/chemicalequationinput.html b/common/lib/capa/capa/templates/chemicalequationinput.html index f705ec3d06..becd2a330a 100644 --- a/common/lib/capa/capa/templates/chemicalequationinput.html +++ b/common/lib/capa/capa/templates/chemicalequationinput.html @@ -29,10 +29,8 @@ % endif

-
- +
-

diff --git a/common/static/js/capa/chemical_equation_preview.js b/common/static/js/capa/chemical_equation_preview.js index f271aaf8df..90ce27ad11 100644 --- a/common/static/js/capa/chemical_equation_preview.js +++ b/common/static/js/capa/chemical_equation_preview.js @@ -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)); }