Forum Moderators: open

Message Too Old, No Replies

Looking for Thickbox/Lightbox like script

         

alexey9

8:06 am on Sep 19, 2007 (gmt 0)

10+ Year Member



Hello guys,

I'm looking for Thickbox [jquery.com] like script. It's great script that allows to show pictures in big popup-like windows. However it doesn't work with links, created with Javascript (with innerHTML).

Do you guys know any similar scripts?

authortitle

8:56 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



I had the same problem recently. The issue is that when you call thickbox.js in your page, it calls tb_init(..) which scans through all the <a> tags in your page and gives those with class="thickbox" the appropriate 'onclick' action to open the Thickbox. If you add a new link through Javascript/DHTML, thickbox isn't listening out for changes to the page so these links don't get the onclick handler added, even if you give them class="thickbox" when you create them.

I got round it by manually adding tb_show to the onclick handler of each link I created using Javascript, so something like (using Jquery):

$('#editimages img').each(function()
{
$(this).click(function()
{
tb_show("Replace Image","admin/pictures/replace.php?imgsrc="+this.src+"&imgwidth="+this.width+"&imgheight="+this.height+"&width=500&height=500&KeepThis=true&TB_iframe=true&");
imageClick(this);
});
}

You might be able to find a way to just call tb_init() whenever you create a new link but I remember this didn't seem to work for me.

Good luck anyway, understand the problem is half of the solution ;)

[edited by: authortitle at 9:10 pm (utc) on Sep. 19, 2007]

authortitle

9:08 pm on Sep 19, 2007 (gmt 0)

10+ Year Member



i don't have time to try it right now but i can't see why just calling:

tb_init('a.thickbox, area.thickbox, input.thickbox');

whenever you create a new link shouldn't work.

if it causes two thickboxes to open on existing links (it shouldn't i don't think?) i'll have a look in thickbox.js and see if that can be changed

alexey9

9:32 am on Sep 21, 2007 (gmt 0)

10+ Year Member



Thanks for quick reply.

I'm not really good at Javasript (I've learnt it just few weeks ago), but I'd really like to make Thickbox work.

I've tried to call tb_init after I use innerHTML, but it still doesn't work:

tb_init('a.thickbox, area.thickbox, input.thickbox');

Instead of thickbox, browser just loads the photo as if it was just simple link to the image. :(

It would be really great if you could tell me how to modify thickbox.

vitaminRAD

9:50 pm on Sep 24, 2007 (gmt 0)

10+ Year Member



I would check this out -

[digitalia.be...]

(free - compact - stable!)

authortitle

4:17 pm on Sep 26, 2007 (gmt 0)

10+ Year Member



i just tried it out... calling tb_init works for me. if you are allowed by the forum rules, post up the code

alexey9

10:14 am on Sep 30, 2007 (gmt 0)

10+ Year Member



Thanks. I made it work with tb_init.

Another problem is sometimes I get double image. I mean image displays twice.

I wonder why does it happen? I mean it doesn't happen always.