The goal is to look if the modified Prototype actually works. Let's make an object hide and show on user action.
hide
this is a test object which should hide and show on user action
I created an action link and object on which action will be taken. I gave them ids test_hide and test_hide_button
Prototype accesses the DOM elements using $( function. Because it is a modification, I have to use id_name
)$ID(.id_name
)
Example uses hide() and show() Prototype functions.
<a id='test_hide_button' onclick="showhide('test_hide')">hide</a>
<p id='test_hide'>this is a test object which should hide and show on user action</p>
<script type='text/javascript'>
function showhide( id ) {
if ($ID(id).hidden) {
$ID(id).show();
$ID(id).hidden = false;
$ID(id + '_button').innerHTML = 'hide';
} else {
$ID(id).hide();
$ID(id).hidden = true;
$ID(id + '_button').innerHTML = 'show';
}
}
</script>
Trackback URL for this post:
http://piotr.zalewa.info/trackback/8









Comments
Will do, But I am really thinking of fully replace drupal's jQuery into Prototype. Haven't found anything like this for the moment.
Thanks for this! I used it with some modifications and it worked well!
Keep posting more of such code!
Thanks! Prem
Post new comment