Implementing Lightbox

JavaScript and client side scripting.

Moderator: General Moderators

Post Reply
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Implementing Lightbox

Post by theBond »

~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.


I want to implement lightbox through ajax.

example usage given in the site http://www.huddletogether.com/projects/lightbox/
<a href="images/image-1.jpg" rel="lightbox" title="my caption">image #1</a>

Code: Select all

<script language="Javascript">
 
function CallAjax(url)
{
  http=CreateXHTML();
  
  
  http.open("GET", url, true);
  
  http.onreadystatechange=function(){
    if(http.readyState==4 && http.status==200)
    {
      alert(''); //Which div should i have to refer?
    }
  }
  
  http.send(null);
}
 
</script>
In the link page i am using, <a href="javascript:void(0);" onClick="CallAjax($url)">lightbox link</a>


~pickle | Please use [ code=html ], [ code=php ], etc tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: :arrow: Posting Code in the Forums to learn how to do it too.
User avatar
dhrosti
Forum Commoner
Posts: 90
Joined: Wed Jan 10, 2007 5:01 am
Location: Leeds, UK

Re: Implementing Lightbox

Post by dhrosti »

why do you need to call it using ajax?
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Re: Implementing Lightbox

Post by theBond »

why do you need to call it using ajax?
1. I would like to display details of the image. If i use, <a href="images/image-1.jpg" rel="lightbox" title="my caption">link_text</a> I have to send it in title tag and if it is a text link then onmouseover the data are displayed.

2. The table structure is in such a manner it would be easy to retrieve all data of the item from many related tables of a single item.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Implementing Lightbox

Post by RobertGonzalez »

Lightbox is simple to use. Are you using the core lightbox library or are you using an library with lightbox as a plugin (like jQuery, which makes this super easy to do).

Oh yeah, this is being moved to client side.
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Re: Implementing Lightbox

Post by theBond »

Lightbox is simple to use. Are you using the core lightbox library or are you using an library with lightbox as a plugin (like jQuery, which makes this super easy to do).

Oh yeah, this is being moved to client side.
I am not using any plugin.
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Implementing Lightbox

Post by RobertGonzalez »

Let me ask that different. Are you using a JS library at all (jQuery, Dojo, Moo tools, Prototype)?
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Re: Implementing Lightbox

Post by theBond »

The file that i downloaded from http://www.huddletogether.com/projects/lightbox/ uses prototype.js
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Implementing Lightbox

Post by RobertGonzalez »

Sorry, I know nothing about prototype. I know jQuery has a very easy to use Ajax interface to lightbox (or thickbox) which makes it really easy to use.
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Re: Implementing Lightbox

Post by theBond »

Its OK, Atleast can u tell me how to disable the caption being shown on mouseover when i give textlinks?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Implementing Lightbox

Post by RobertGonzalez »

If the captions are in title attributes then you are not going to be able to keep them from showing.
theBond
Forum Newbie
Posts: 19
Joined: Thu Jul 17, 2008 7:46 pm

Re: Implementing Lightbox

Post by theBond »

If the captions are in title attributes then you are not going to be able to keep them from showing.
Yes. what's the alternative?
User avatar
RobertGonzalez
Site Administrator
Posts: 14293
Joined: Tue Sep 09, 2003 6:04 pm
Location: Fremont, CA, USA

Re: Implementing Lightbox

Post by RobertGonzalez »

There is no alternative. The title attribute is a valid piece of markup and is commonly used by lightbox to render the caption when invoked.
Post Reply