Is that information already loaded in the page you are currently on?
If so, couldn't the function just swap out the content?
If not, and the more correct way of doing this, would be to hit some
sort of restful resource with link_to_remote and have it return
javascript to update the page with the retrieved information.
There is an image to correspond with this. The image is not a problem; I
have gotten this image to change on click with 'link_to_function'.
The information above, excluding the image of course, also needs to
change on click.
If you know at the time of rendering the initial display what
information needs to be displayed when the link is clicked, then you
should probably render both sets of info inside two <div>s: one with
style="display:block" and the other with style="display:none". Then
your link_to_function can simply toggle the display settings.
If you don't, then I'd recommend using a link_to_remote instead and
hitting the server to remove the first <div> and render the second
using an RJS template.
There is an image to correspond with this. The image is not a problem; I
have gotten this image to change on click with 'link_to_function'.
The information above, excluding the image of course, also needs to
change on click.
If you know at the time of rendering the initial display what
information needs to be displayed when the link is clicked, then you
should probably render both sets of info inside two <div>s: one with
style="display:block" and the other with style="display:none". Then
your link_to_function can simply toggle the display settings.
I know what information needs to be displayed when the user clicks the
tab with the name on it. There are 4 tabs and therefore 4 pieces of
information that all use the same class. I'm trying to use a toggle
feature but it doesn't seem to be working.
If you know at the time of rendering the initial display what
information needs to be displayed when the link is clicked, then you
should probably render both sets of info inside two <div>s: one with
style="display:block" and the other with style="display:none". �Then
your link_to_function can simply toggle the display settings.
I know what information needs to be displayed when the user clicks the
tab with the name on it. There are 4 tabs and therefore 4 pieces of
information that all use the same class. I'm trying to use a toggle
feature but it doesn't seem to be working.
'not working' isn't much to go on in terms of providing additional
help. Post some code; both the html.erb and the js function and maybe
we can say more.
Indeed it's not. See below, the functions used:
<SCRIPT language="javascript">
function changeImage(pictureLocation)
{
$('member_image').src = pictureLocation;
}
function toggleInformation(name)
{
var element = document.getElementById(name);
if (element.style.display != 'block' || element.style.display ==
'none')
{
element.style.display = 'block';
}
else
{
element.style.display = 'none';
}
}
</SCRIPT>