Files
edx-platform/common/static/js/capa/chemical_equation_preview.js
Victor Shnayder f4d8df94dd Make chem preview more robust
- give the preview div an id, use that to look it up instead of dancing around in the DOM
2012-10-14 11:35:32 -04:00

25 lines
729 B
JavaScript

(function () {
update = function() {
function create_handler(saved_div) {
return (function(response) {
if (response.error) {
saved_div.html("<span class='error'>" + response.error + "</span>");
} else {
saved_div.html(response.preview);
}
});
}
prev_id = "#" + this.id + "_preview";
preview_div = $(prev_id)
$.get("/preview/chemcalc/", {"formula" : this.value}, create_handler(preview_div));
}
inputs = $('.chemicalequationinput input');
// update on load
inputs.each(update);
// and on every change
inputs.bind("input", update);
}).call(this);