This problem probably exists for a wider range of events and elements, but I tried it with an input element and its onclick event. I wanted another checkbox to be disabled if this checkbox was unchecked. So all I need is to set the small javascript function as the checkbox’ onclick event. No such luck in WebDSL. Eventually I hacked around it (summarised):

<script type="text/javascript">
	function checkWriteRights() {
		el = document.getElementById( detailCheck );
		el2 = document.getElementById( writeCheck );
		if( el.checked ) {
			el2.disabled = false;
		}
		else {
			el2.disabled = true;
		} 
	}
	function hackInOnClick() {
		el = document.getElementById( "detailCheck" );
		el.onclick = checkWriteRights;
	}
</script>
table {
	row {
		"Details:" input(f.hasDetailRight)[id := detailCheck]
	}
	row {
		"Writing:" input(f.hasWriteRight)[id := writeCheck]
	}
}
<script type="text/javascript">
	hackInOnClick();
</script>

But the better way of doing this would be:

<script type="text/javascript">
	function checkWriteRights() {
		el = document.getElementById( detailCheck );
		el2 = document.getElementById( writeCheck );
		if( el.checked ) {
			el2.disabled = false;
		}
		else {
			el2.disabled = true;
		} 
	}
</script>
table {
	row {
		"Details:" input(f.hasDetailRight)[id := detailCheck, onclick := "javascript:checkWriteRights()"]
	}
	row {
		"Writing:" input(f.hasWriteRight)[id := writeCheck]
	}
}

Basically all that’s needed is to allow a string in the event and then just copy it into the HTML directly. Or so I think :)

Submitted by Thomas Schaap on 31 March 2010 at 14:17

On 6 April 2010 at 13:35 Danny Groenewegen commented:

String expression for event was inadvertently disabled by a constraint, fixed in revision 3806

Log in to post comments