Hi Mai, On May 9, 2011, at 1:59 PM, Mai Nguyen wrote:
> Hello Ajax gurus,
>
> I am using the AjaxUpdateLink to update a table inside a page instead of
> refreshing the whole page.
> However, the link only refreshes the Ajax Update Container (which wraps the
> table) briefly while the user clicks on the link.
> Can someone point to me how to make sure the container remains updated until
> the user clicks on the link again to hide the contents?
> I wish to allow the user to explicitly click on "Hide Explanation" to hide
> the explanation.
>
> Currently with the following wod description, an onClick causes the link to
> update the container correctly, but it only lasts a few seconds, then the
> update container returns to its previous state.
You are doing it wrong. :-) The AjaxUpdateLink is to update the browser
display with new information from the server. You are just updating the DOM
here so there is no need for a trip to the server. Try this instead:
ExplanationLink: WOHyperlink {
action = context.page; // Not used, but keeps WO happy
onClick = "show_explanation(this); return false;";
}
function show_explanation(element) {
case_number = element.parentNode.parentNode.id;
explanation_row = document.getElementById(case_number +
"_status");
if (explanation_row.style.display != 'none') {
element.innerHTML = "Hide Explanation";
explanation_row.style.display = 'none';
} else {
element.innerHTML = "What does this mean?";
explanation_row.style.display = '';
}
};
Chuck
>
> Here is the description of the link:
>
> ExplanationLink: AjaxUpdateLink {
> updateContainerID = "SearchResultsUpdateContainer1";
> action = showStatusExplanation;
> onClick = "show_explanation(this)";
> evalScripts = true;
> onComplete = "SearchResultsUpdateContainer1Update()";
> }
>
> function show_explanation(element) {
> case_number = element.parentNode.parentNode.id;
> explanation_row = document.getElementById(case_number +
> "_status");
>
> if (element.innerHTML == "What does this mean?") {
> element.innerHTML = "Hide Explanation";
> explanation_row.style.display = '';
> } else {
> element.innerHTML = "What does this mean?";
> explanation_row.style.display = 'none';
> }
> };
>
> public WOActionResults showStatusExplanation() {
> return null;
> }
> Is an action binding required here? If yes, since the onClick JS Script
> already takes care of the display, can the action just return null?
>
> Thanks for any hints,
>
> -mai
>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/chill%40global-village.net
>
> This email sent to [email protected]
--
Chuck Hill Senior Consultant / VP Development
Come to WOWODC this July for unparalleled WO learning opportunities and real
peer to peer problem solving! Network, socialize, and enjoy a great
cosmopolitan city. See you there! http://www.wocommunity.org/wowodc11/
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
