---
Working on the proble why adding/deleting a drug removes comments, name, birthday, etc. Improved watir test to check for all fields.
I think I must modify set PrescriptionDrug.prescription_comment to use textarea.set_attribute 'onBlur'/'onFocus to save the value in a global variable of the Javascript. What I found out is that
Using https://developer.mozilla.org/en-US/docs/Web/Guide/API/DOM/Storage, which says Mozilla-based browsers, Internet Explorer 8+, Safari 4+, and Chrome all provide a working implementation of the DOM Storage specification.
. Now I am ready to get value of the comments after deleting/adding a drug in the domReady-function. Trying onLoad on a single element. This did not work. Must define an ID for each element and set in on the main PrescriptionForm.onload method like
require(["dojo/domReady!"], function(){ document.getElementById('searchbar').focus(); console.log ('PrescriptionForm.onload getItem prescription_comment_0 is : ' + sessionStorage.getItem('prescription_comment_0', "default bemerkung")); var x=document.getElementById('id_comment_0'); console.log ('PrescriptionForm.onload x is : ' + x); if (x != null) { x[0].value = sessionStorage.getItem('prescription_comment_0', "default bemerkung"); } });
Now must pack this construct into a general javascript function and use it for all concerned field.
Solved these problems, but no the comments do not appear on the print page as its ruby counterparts were not updated. Also the comments are missing in the exported csv.
Zeno requested me to push the incomplete change. Done with commit Add interactions to print. Preserve comments when adding/deleting drugs.
Add to fix two syntax errors in javascript with Fix Javascript syntax error when entering comments
Also remarking that I get JavaScript-syntax errors as it seems that my ruby code for (index = #{@index}; index < 99; ++index) {
gets translated to for (index = 1; index < 99; ++index) {
. Maybe I must use "
instead of %(
to start a text constant. Banging my head why (and where exactly) I still get Uncaught SyntaxError: Unexpected token ILLEGAL