I'm trying to write what I thought would be an easy Ruby. It's beginning to feel otherwise. At present I'm stumped by the following.
My Ruby depends on getting a list of scenes and layers from the model. It then draws the UI, which is at heart an array of checkboxes, one for each layer/scene intersection. Hence the UI cannot be built into the HTML, it has to be generated by JavaScript.
I've distilled down to a simple HTML, .js combo. I've discovered that you can't "document.write" the same text that would work from HTML if you want to include an onclick handler. The workaround I've been fiddling with is to create the checkbox, getElementById it and attach a reference to its onclick property. The following code shows this with buttons. The problem is, this code runs fine in Opera, but not in the browser whose name must never be spoken.
<!-- a.html -->
<html>
<body onload='init()'>
<script src='a.js'> </script>
</body>
</html>
// a.js
var clicker = function() {
alert( 'That tickles!' );
}
var clicker2 = function() {
alert( 'That tickles, too!' );
}
function init() {
document.write( '<button id=b1> Click </button>' );
document.getElementById( 'b1' ).onclick = clicker;
// this doesn't work;
document.write(
'<button id=b2 onclick=clicker2()> Click me, too </button>' )
// unless you add;
document.getElementById( 'b2' ).onclick = clicker2;
}
I do not have enough hair left to continue pulling it out at the present rate. Help!