Load from ajax ?

Page: 1

Author Post
Leeloo
Guest
Hi,
is it possible to launch Floatbox from a link placed in an external page loaded by ajax ?
I did a few tries without any result.
Administrator
Registered: Aug 2008
Posts: 3382
Yes.
This is covered deep in the bowels of the docs. Take a look at the write up on the fb.tagAnchors function in the programming active content section of the docs.
Leeloo
Guest
I have read the documentation, but i don't understand where i have to put the fb.tagAnchors command :
- add an onclick="fb...." on link in ajax loaded page
- create a function which calls fb.tagAnchors on main page

Sorry for the inconvenience but my javascript knowledge is really poor.
Administrator
Registered: Aug 2008
Posts: 3382
Leeloo,
My apologies for a crap first answer. I wasn't paying enough attention. I hope you didn't waste too much time as a result. When I answered, I was thinking about folks who update their base page with floatbox links that come in via ajax. Those folks need to run fb.tagAnchors against that new content.

But I think you just mean you are loading some content in floatbox via ajax and you want some floatbox-enabled links in that content. Easy. Just set those links up as you would floatboxed links on the base page - exactly the same. The floatbox code will find them. You don't need to run tagAnchors for content that is displayed in floatbox via ajax.

If you are already doing this and it's not working, let me have look online and I'll see why.
« Last edit by admin on Sat Jan 24, 2009 2:58 pm. »
Leeloo
Guest
Here is my test page

1st link : load a page via ajax which contains a link i want to floatbox
2nd link : simple ajaxed page, nothing more
3rd link : floatboxed classic link in parent page

All i want is to launch floatbox as if external pages were loaded in an iframe.
Administrator
Registered: Aug 2008
Posts: 3382
Ah. So my first answer was not crap. You are updating the base page content via ajax, and want a floatboxed link active in the updated content. So after the update, you have to run fb.tagAnchors as advertised. You make this call after the javascript ajax fetch completes. In your case, you can add this call to your "loadpage" function. After the line document.getElementById(containerid).innerHTML=page_request.responseText add the line fb.tagAnchors(document.getElementById(containerid)); (and don't forget to put a semi-colon after the preceding line).
Leeloo
Guest
Great great thanks for your help !!!

Now i see the good location, nothing like i tried... i was always putting the command on anchors on the main page (with javascript:ajaxpage(...) link) or ajaxed pages.

Page: 1