logo       

Behaviour and scriptaculous: msg#00143

lang.ruby.rails.spinoffs

Subject: Behaviour and scriptaculous

I have a <div> that I want to toggle its visibility. I have "hide"
text which makes it hide an makes the text "show" visible.

My problem is I don't want the "hide" text to display if javascript is
disabled. So it starts out as display:none. I can then make it
visible by window.onload.

The problem is when I use the onload handler then the text does
display at startup, but clicking on it has no effect.



This is what I tried:

<div id="hiddentable">
<span id="tablehide" style="display:none;">Hide Table</span>

(( show table here ))

<span id="tableshow" style="display:none;">Show Table</span>
</div>


I'm using Behaviour to register the javascript:

/* make the "hide" text visible if javascript is enabled */
/* this makes the "hide" text not do anything -- comment out and works */
window.onload = function() {
new Effect.Appear(document.getElementById('tablehide'));
}

var hide_rules = {
'#tablehide' : function(e) {
e.onclick = function() {
new Effect.BlindUp(document.getElementById('hiddentable'));
new Effect.Appear(document.getElementById('tableshow'));
}
},

'#tableshow' : function(e) {
e.onclick = function() {
new Effect.BlindDown(document.getElementById('hiddentable'));
new Effect.Fade(this);
}
},
};

Behaviour.register(hide_rules);


I'm reasonably new to Behaviour/Prototype/Scriptaculous, in case you
were wondering...





--
Bill Moseley
moseley-kv6DSSSScSo@xxxxxxxxxxxxxxxx


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

News | FAQ | advertise