how exactly do I...

Page: 1

Author Post
NBB
Guest
I keep reading about fb.tagAnchors like in a thread from Nov 2008

"After updating a panel, you need to run the fb.tagAnchors function"

or a more recent thread

"After you dynamically load content, you have to run fb.tagAnchors() against that content to light it up. See the API reference for details."

I read the API reference but still have no ideas what to do.

If I'm running a page that uses ajax content, the new content does not run the floatbox. From my reading I understand that using the fb.TagAnchors can solve this issue. My problem is I have no idea how to use it and where to put it. Is it used in an "onclick" I'm not so good at writing javascript :)

any help is appreciated!
Administrator
Registered: Aug 2008
Posts: 3382
I've got an update to the docs coming out real soon now that covers this topic better. Here's the excerpt. The key is to find the place in your existing javascript where your ajax content is inserted into your page, and run the two lines fb.anchors.length = 0; and fb.tagAnchors(document); after that insertion.
Quote
Dynamically loading floatbox content via AJAX

When floatbox first loads on a page, it runs its tagAnchors function to inventory all the floatbox-enabled anchors and area maps on the page, and to add the required onclick action to those anchors. If you subsequently dynamically update a portion of your page with content from an AJAX fetch, any floatbox-enabled anchors in that content won't be in floatbox's inventory and won't have the required onclick action attached to them. So what you have to do is to run the tagAnchors function against your new content after it arrives.

Your existing AJAX content insertion might look something like this:
if (xmlReq.readyState == 4) {
document.getElementById('myXmlDiv').innerHTML = xmlReq.responseText;
}

Light up the floatbox anchors in that dynamic content by adding the following two lines after that insertion:
if (xmlReq.readyState == 4) {
document.getElementById('myXmlDiv').innerHTML = xmlReq.responseText;
fb.anchors.length = 0;
fb.tagAnchors(document);
}
This clears the existing inventory of anchors and then re-inventories the entire document, including the freshly added new content. Now your new floatbox anchors will work.

If you are using an ASP.NET UpdatePanel, you can set a callback function to fire the floatbox tagging after your panel has finished updating. Put this javascript on the page:
function pageLoad(sender, args) {
if (args.get_isPartialLoad()) {
fb.anchors.length = 0;
fb.tagAnchors(document);
}
}

Page: 1