Add a chemicalequationinput with live preview
- architecturally slightly questionable: the preview ajax calls goes to an LMS view instead of an input type specific one. This needs to be fixed during the grand capa re-org, but there isn't time to do it right now. - also, I kind of like having a generic turn-a-formula-into-a-preview service available
This commit is contained in:
1
common/static/js/capa/README
Normal file
1
common/static/js/capa/README
Normal file
@@ -0,0 +1 @@
|
||||
These files really should be in the capa module, but we don't have a way to load js from there at the moment. (TODO)
|
||||
12
common/static/js/capa/chemical_equation_preview.js
Normal file
12
common/static/js/capa/chemical_equation_preview.js
Normal file
@@ -0,0 +1,12 @@
|
||||
(function () {
|
||||
var preview_div = $('.chemicalequationinput .equation');
|
||||
$('.chemicalequationinput input').bind("input", function(eventObject) {
|
||||
$.get("/preview/chemcalc/", {"formula" : this.value}, function(response) {
|
||||
if (response.error) {
|
||||
preview_div.html("<span class='error'>" + response.error + "</span>");
|
||||
} else {
|
||||
preview_div.html(response.preview);
|
||||
}
|
||||
});
|
||||
});
|
||||
}).call(this);
|
||||
Reference in New Issue
Block a user