Webmaster Forum


Go Back   Webmaster Forum > Web Development > Coding Forum

Coding Forum Problems with your code? Discuss coding issues, including JavaScript, PHP & MySQL, HTML & CSS, Flash & ActionScript, and more.


Reply
 
LinkBack Thread Tools Display Modes
Share |
  #1 (permalink)  
Old 03-21-2011, 12:16 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
Calling jquery colorbox on dynamic content

Hello ... I've completed a photo gallery for a client that includes 4 different photo albums that all run the colorbox plugin to generate slide shows (http://www.crucean.com/gallery.php).

I thought the four albums stacked on top of each other looked a little to bulky ... I wanted to make a little javascript player that would advance the four photo albums into a div (id="albums") depending on which button is clicked.

Here's what I have ... it works perfectly ... except now the colorbox plugin doesn't work (http://www.crucean.com/galleryNew.php).

I think this is because the content that I am calling colorbox on, is generated dynamically by the JS code variables (albumCont1, albumCont2, albumCont3 and albumCont4) ... yet, it doesn't seem like that should matter ... HTML is HTML, right? Shouldn't matter how it was generated?

The other possible cause of this may just be the path that colorbox uses to search for <a> tags that have the rel="album#" tags ... right now it is set to:

$("a[rel='album1']").colorbox({transition:"fade"});
$("a[rel='album2']").colorbox({transition:"fade"});
$("a[rel='album3']").colorbox({transition:"fade"});
$("a[rel='album4']").colorbox({transition:"fade"});

Any ideas on how to call my plugin on this dynamically generated content?

Thanks
| sc
 
Reply With Quote
  #2 (permalink)  
Old 03-21-2011, 12:53 PM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
You need to add the elements to the DOM properly for it to work like that.

What you should really do is have it all in the HTML right from the start, however, and just hide the divs with CSS. Upon clicking the buttons you use jQuery to change the CSS of the divs, showing the one corresponding to the button and hiding the others.
 
Reply With Quote
  #3 (permalink)  
Old 03-23-2011, 06:05 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
That's a nice bit of info ... I wouldn't have thought to do that. Thanks!

Sweet avatar BTW! The pipe adds a nice air of sohpisitcation.

| sc
 
Reply With Quote
  #4 (permalink)  
Old 03-24-2011, 04:26 PM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
That's a nice bit of info ... I wouldn't have thought to do that. Thanks!

Sweet avatar BTW! The pipe adds a nice air of sohpisitcation.

| sc
No problem (I'd be delighted if you'd click the green (+) by the post by the way ), and thank you Pipe-smoking is quite relaxing and also quite obligatory if you've got a beard, hehe.
 
Reply With Quote
  #5 (permalink)  
Old 03-24-2011, 11:18 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
I hear you ... once I grew a beard I was shocked to find a smoking pipe had been sent to me in the mail ... some things just go together.
 
Reply With Quote
  #6 (permalink)  
Old 03-25-2011, 08:51 AM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
I hear you ... once I grew a beard I was shocked to find a smoking pipe had been sent to me in the mail ... some things just go together.
You serious? xD

I'm actually thinking of starting a blog about pipes, I'm still a novice with only about five pipes and six or seven tobaccos, but it's fun to write about.
 
Reply With Quote
  #7 (permalink)  
Old 04-04-2011, 07:04 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
Are you still out there? I'm trying to execute your jquery suggestion but my brain no parse the simple or something ...

I think my trouble is in targeting the buttons that will advance my photo galleries ... each button should load the appropriate gallery ... can you look to see how I blew the button targeting? Here's the link ...

http://www.crucean.com/galleryJquery.php

Smoke one for me ...
| scott
 
Reply With Quote
  #8 (permalink)  
Old 04-04-2011, 11:15 PM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
Are you still out there? I'm trying to execute your jquery suggestion but my brain no parse the simple or something ...

I think my trouble is in targeting the buttons that will advance my photo galleries ... each button should load the appropriate gallery ... can you look to see how I blew the button targeting? Here's the link ...

http://www.crucean.com/galleryJquery.php

Smoke one for me ...
| scott
Code:
$('.albums input id #butt1_1').click(function(){
should work better if you change it to
Code:
$('.albums input#butt1_1').click(function(){
and you have to remove the onclick for the inputs, the method is undefined and will throw an exception
 
Reply With Quote
  #9 (permalink)  
Old 04-05-2011, 09:16 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
Still no worky ... hmmmm ... I wonder, is it because I used an id and a class on the same div? As in:

<!-- begin album1 div -->
<div id="gallery1" class="albums">

http://www.crucean.com/galleryJquery.php

Thanks again.
| scott
 
Reply With Quote
  #10 (permalink)  
Old 04-06-2011, 12:03 AM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
Still no worky ... hmmmm ... I wonder, is it because I used an id and a class on the same div? As in:

<!-- begin album1 div -->
<div id="gallery1" class="albums">

http://www.crucean.com/galleryJquery.php

Thanks again.
| scott
You need $(function() { /*code here*/ }); surrounding the code starting at line 48 ending at line 73
 
Reply With Quote
  #11 (permalink)  
Old 04-06-2011, 09:56 AM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
Beautiful ... should have seen that coming. All of my functions should have been nested in the giant mondo function ... thanks for your help!

Now i just want to make it degrade for the non js clowns ... people without javascript should just see the four photo albums the way it was before ... I have a few ideas on how to try this ... more later if I go down in flames ...
 
Reply With Quote
  #12 (permalink)  
Old 04-06-2011, 09:57 AM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
Beautiful ... should have seen that coming. All of my functions should have been nested in the giant mondo function ... thanks for your help!

Now i just want to make it degrade for the non js clowns ... people without javascript should just see the four photo albums the way it was before ... I have a few ideas on how to try this ... more later if I go down in flames ...
Since it's all in the code they will actually show. The hide() methods won't be called on the albums Unless you've hidden them with CSS first
 
Reply With Quote
  #13 (permalink)  
Old 04-06-2011, 07:59 PM
scgroove's Avatar
Contributing Member
Latest Blog:
None

 
Join Date: 01-17-11
Location: Chicago
Posts: 57
iTrader: 0 / 0%
Okay ... that makes sense ...

I got it now to where jquery hides the four input buttons when javascript is disabled ... pretty cool.

http://www.crucean.com/galleryJquery.php

Do you see any problems with the way i did this?

| sc
 
Reply With Quote
  #14 (permalink)  
Old 04-06-2011, 11:25 PM
nemrod's Avatar
v7n Mentor
 
Join Date: 12-21-10
Location: Sweden
Posts: 461
iTrader: 0 / 0%
Quote:
Originally Posted by scgroove View Post
Okay ... that makes sense ...

I got it now to where jquery hides the four input buttons when javascript is disabled ... pretty cool.

http://www.crucean.com/galleryJquery.php

Do you see any problems with the way i did this?

| sc
It's an interesting solution and seems to work, but to separate the JS from the mark-up I would instead use regular CSS to set "display: none" on the div surrounding the buttons and use jQuery at the top of the page to set "display: block" (or .show(), same effect). If the user doesn't have JS they will simply stay hidden, but if they have JS it will show the buttons.
 
Reply With Quote
Go Back   Webmaster Forum > Web Development > Coding Forum

Reply

Tags
colorbox, javascript help, jquery


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Helping choosing Jquery plugin to slide content netentropy Coding Forum 14 03-29-2011 06:49 AM
Calling Jquery Colorbox via URL scgroove Coding Forum 3 02-16-2011 12:57 PM
Trying to randomise a jQuery content slider alecrust Coding Forum 1 04-08-2010 03:26 PM
Dynamic Content & Duplicate Content briz_dad SEO Forum 6 02-26-2010 03:54 PM


V7N Network
Get exposure! V7N I Love Photography V7N SEO Blog V7N Directory


All times are GMT -7. The time now is 12:50 PM.
Powered by vBulletin
Copyright © 2000-2013 Jelsoft Enterprises Limited.
Copyright © 2003 - 2013 Escalate Media LP




Search Engine Optimization by vBSEO 3.6.0 RC 2 ©2011, Crawlability, Inc.