Dynamic FBML Attributes
From within your FBML, you can apply special attributes to specific FBML and HTML tags that allow you to perform AJAX, dynamically hide and show elements, and other common JavaScript functions. The methods in this section offer you an easy way to get things done without having to worry too much about getting JavaScript to work in Facebook.
Visibility Attributes
With just a few attributes added to most elements in your FBML, you can dynamically allow the displaying and hiding of data upon a click of a mouse button. The following attributes can include more than one element ID, separated by commas:
clicktoshowWhen the current element is clicked, the element IDs contained will switch to
display:block.clicktohideWhen the current element is clicked, the element IDs contained will switch to
display:none.clicktotoggleWhen the current element is clicked, the element IDs contained will switch between their existing state and
display:noneand vice versa, depending on the current state.clickthroughSet this to
truewhen using radio buttons or checkboxes with which you want to useclicktoshow,clicktohide, orclicktotoggle. Not settingclickthrough="true"when using these elements will render the element inoperable.
Here are three examples that show how to use the visibility attributes:
<div id="example1" style="display:none">Visible</div>
<a href="#" clicktoshow="example1">Click here to make "Visible"
appear.</a><div id="example2">Visible2</div> <a href="#" clicktohide="example2">Click ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access