same form, different functions, different issue. Like I said, it now
works in FF, Chrome, Safari & IE8. However in IE compatibility mode
(or browser mode= IE7), it fails.
Basically, we're using some JS to submit the contents of the author
fields on a form (the same rows that were not being added before). As
I'm not as familiar with IE's developer tools as with firebug, I can't
yet point to exactly what is causing it to fail.
Here are the 2 functions in use:
function colUpdateAuthor (evt) {
// Update the author lastname/firstname fields from/to
// a hidden form field.
// Grab which field changed, plus its parent
var target = evt.target;
var parent = target.parentNode;
base2.DOM.bind(parent);
// Next, grab the hidden field and its value, and split into
// lastname/firstname parts
hidden = parent.querySelector("input.hidden");
var hiddenvalue = hidden.value;
var hiddenvalues = hiddenvalue.split(", ");
var hiddenlast = hiddenvalues[0];
var hiddenfirst = hiddenvalues[1];
// Based on which visible field we are on, do an update
var whichpart = target.getAttribute("name").split("-")[1];
if (whichpart == "lastname") {
if (target.value == '' && hiddenlast) {
// If the current value is empty, that means this
function
// is called on page load. Thus, read *from* the hidden
field
// and *into* the visible field.
target.value = hiddenlast;
} else {
// If there is a @value attribute, that means we are
// called after pageload, when onchange is called.
Therefore,
// assign *from* the target *to* the hidden field.
// If hiddenfirst is undefined, we are an on add screen,
// not an edit.
if (target.value.length > 0) {
hidden.value = target.value + ", " + hiddenfirst;
} else {
hidden.value=hiddenfirst;
};
};
} else if (whichpart == "firstname") {
if (target.value == '' && hiddenfirst) {
// If the current value is empty, that means this
function
// is called on page load. Thus, read *from* the hidden
field
// and *into* the visible field.
// If hiddenfirst is undefined, we are an on add screen,
// not an edit.
target.value = hiddenfirst;
} else {
// If there is a @value attribute, that means we are
// called after pageload, when onchange is called.
Therefore,
// assign *from* the target *to* the hidden field.
if (target.value.length > 0){
hidden.value = hiddenlast + ", " + target.value;
} else {
hidden.value=hiddenlast;
};
};
};
};
/* Now wire up functions to nodes by scannning the DOM.
This is called on page load. */
function colInit () {
// See if we're on a form, and if so, do some things
var isform = document.querySelector("head meta
[name=formcontroller]");
if (isform) {
// Register some handlers based on which form type
var formtype = isform.getAttribute("content");
if (formtype == 'file' || formtype == 'libraryfile') {
document.querySelectorAll("#authors-container input
[type=text]").forEach(function(element) {
// Handle T1236, split Authors into lastname/firstname
element.addEventListener("change", colUpdateAuthor,
false);
// Simulate the first update by pretending to fire the
event
var evt = new Object();
evt.target = element;
colUpdateAuthor(evt);
});
};
};
}
base2.DOM.bind(document);
document.addEventListener('DOMContentLoaded', colInit, false);
Any thoughts or suggestions you have will be appreciated.
Thanks, Kyle