views:

784

answers:

1

I'm using Dynamic Drive Step Carousel Viewer v1.8 so show a series of item images (div class="panel") within a #scroll.belt div. Each image panel includes a hidden <p> containing alarger version of the image and some text description. So far, so good.

When a user clicks on any image, I want the hidden <p> associated with that image to appear and float above the #scroll.belt div. I've had success using jquery show/hide code to create the effect in a stand-alone panel, but I can't get it to work properly on multiple panels (it either opens ALL hidden <p> at one time, or noe at all), nor can have I been able to integrate the effect into the Step Carousel Viewer's onpanelclick:function(target) parameter.

I'm a noob (obviously) and way behind on this delivery, so any help would be appreciated.

Here's the code for the Step Carousel, with the relevant styles included:

  <script src="http://code.jquery.com/jquery-latest.js"&gt;&lt;/script&gt;
  <script src="js/stepcarousel.js"></script>
  <script>  $(document).ready(function(){    
   $("img.showr").click(function () {        
 $(this).next('p').show("slow");    

});    
 $("img.hidr").click(function () {      
 $(this).parent('p').hide(2000);    
});  

}); 
</script>`<script type="text/javascript">

stepcarousel.setup({
galleryid: 'scroll', //id of carousel DIV
beltclass: 'belt', //class of inner "belt" DIV containing all the panel DIVs
panelclass: 'panel', //class of panel DIVs each holding content
autostep: {enable:true, moveby:1, pause:0},
panelbehavior: {speed:3000, wraparound:true, persist:false},
defaultbuttons: {enable: true, moveby: 1, leftnav: ['images/chrome-l.png', -25, 200], rightnav: ['images/chrome-r.png', -10, 200]},
statusvars: ['statusA', 'statusB', 'statusC'], // Register 3 "status" variables
contenttype: ['inline'] // content type <--No comma following the very last parameter, always!
//optional parameter
//onpanelclick:function(target){
    //custom code here.     
//}    

 })

</script>
  <style>
  p { background:#FFFFFF; margin:3px; width:300px; 
        display:none; position:absolute; left:45%; top: -20px; text-align:left; z-index: 3000;  }
 .over  { z-index: 3000; }
  </style>
  <link href="style-tl.css" rel="stylesheet" type="text/css">
</head>
<body>
 <div id="scroll" class="stepcarousel">
<div class="belt">

  <div class="panel"><img id="showr" class="showr" src="images/1.jpg" width="200px" height="300px" alt="light1" />
  <p><img id="hidr" class="hidr over" src="images/1.jpg" width="300px" height="450px" alt="light1" /> <br />
    <br />
    Display item text description<br />
   $price</p></div>


<div class="panel">
<img id="showr" class="showr" src="images/2.jpg" width="200px" height="300px" alt="light1" />
<p><img id="hidr" class="hidr over" src="images/2.jpg" width="300px" height="450px" alt="light1" /> <br />
    <br />
    Display item text description<br />
   $price</p></div>
</div>
</div>
A: 

I just tried your code and its not a problem with hiding or showing the correct one, its your css style settings for the p tag that is making it look like that

Demo - What it does is show one on top of the other. Since you're using hide and show it does something different then what your intended css wants it to do.

It sets visibility:hidden, visibility:visible: instead of display:none which is what your css does. You need to set your css style setting in a different way. The following Demo example is probably what you want.

Your Answer

TStamper
That works fine when the panels are standalone, but not at all when they are contained within the Image Scroller div. Could the Image Scroller code be blocking the jquery code, and/or is there a work-around?
Caron
Dynamic Drive Step Carousel Viewer v1.8. See a version of your exact workaround (with images) at http://seacliffmm.com/test/tr-lights/Untitled-4.html. You'll see that the scroll function still works--but suddenly not the show-hide. I don't get it either, which is why I'm here.
Caron
Yes, the addclass example. That's exactly what I put up at the demo site, http://seacliffmm.com/test/tr-lights/Untitled-4.html, and it doesn't work--though I agree withyou , it absolutely should.I can't add the code from the demo page in this space, but you should be able to View Code and see it.
Caron
one thing this makes me believe is that the images, by using that step carousel are making them not clickable, so the click event is not being fired, try changing the click event to .focus() and see if that works
TStamper
Theres a step carousel optional parameter that I can include:onpanelclick:function(target){ //custom code here.} Unfortunatly, I don't know the syntax to change that to include that event.
Caron
onpanelclick:function(target){ $(img).click(focus); }???
Caron
Try this: onpanelclick:function(target){if (target.tagName=="IMG") { alert("Im clicked");}}to see if that event is fired
TStamper
YES! That worked for the alert. Now, do I just change that section{ alert("Im clicked");} to... that whole little jquery script?BTW- you're awesome to be staying with me on this.
Caron
ALso, I'm still getting errors on page, as yo can ssee when you refresh the demo page.
Caron
@Caron-the alert is a javascript function, so adding the jquery there would not do it, you would have to either change the jquery to javascript or as I said copy and paste the javascript code within the document.ready function and then you can change the alert to the jquery code.let me know if you have a problem doing that...try it first
TStamper
If you mean "<script type="text/javascript">$(document).ready(function(stepcarousel.setup...[the rest of the stepcarousel stuff]," tried that and it did not work at all. Just broke both features. I may have to change the jquery to javascript, however one does that.
Caron
give me a sec. to upload with javascript because its a little more difficult to have same approach
TStamper
OK, forget that. Back to http://seacliffmm.com/test/tr-lights/Untitled-4.html. I can an image to alert that it's been clicked, but not get the click to perform the 'apply class to p' function. We're so close! Any more ideas... please? (Add whimpering sound).
Caron
you can what an image? you can apply class in javascript as so: setting each 'p' tag with a unique id `<p id="para1"></>` and then: var para1 = document.getElementById("para1"); para1.setAttribute("class", "pp");
TStamper
Soonpanelclick:function(target){if (target.tagName=="IMG") { var para1 = document.getElementById("para1"); para1.setAttribute("class", "pp"); );} ???SO far it's not working--just broke the scroll function again. I'll leave it up so you can see the code, if you want.
Caron
@TStamper, I meant that I can click on an image and get back the alert box, but not the desired effect -displaying the hidden paragraph. It does not show.
Caron
I did, actually, at least para1:div class="panel"><img id="showr" class="showr" src="images/1.jpg" width="200px" height="300px" alt="light1" /> <p id="para1"><img id="hidr" class="hidr" src="images/1.jpg" width="300px" height="450px" alt="light2" /> <br /> <br /> Display item text description<br /> Second $price</p></div>I've now updated all of them, still to no effect.
Caron
are you adding your jquery code to your <head> tag, it should be insde your head tag.
TStamper
It is. Id send you the whole code, but it's too big. The last bit is:onpanelclick:function(target){if (target.tagName=="IMG") { var para1 = document.getElementById("para1"); para1.setAttribute("class", "pp"); );} } It still doesn't work AND it's messing up the scroll function. Now the paragraphs are visible outside/below the main belt.
Caron
well when I check your errors is acting like it doesn support jquery, so just remove the jquery code all together and let me know if the onclick works then. they should be visibile on page load after this change
TStamper
There isn't any jquery code in it - and now it's all messed up with the 'hidden' paragraphs visible underneath the main images.I'm ready to give up, unfortunately, since it just seems to be getting wors and not better. your original solution should have worked inthe first place. THanks for all your effort. If you hink of anything different please send.
Caron
basically at line 21, delete the semi colon and the parantheses before the backet and that should fix the syntax error
TStamper
No joy. Even after fixing the syntax error, it still won't fire the apply class function. The last bit of code is now:onpanelclick:function(target){if (target.tagName=="IMG") { var para1 = document.getElementById("para1"); para1.setAttribute("class", "pp"); )} // content type <--No comma following the very last parameter, always! })</script>
Caron
there is still a syntax error in there,look at the line when you `setAttribute` after the semicolon there should be two close brackets, not a paranthese then a bracket
TStamper
copy and paste this and make sure the comments dont comment out the brackets:onpanelclick:function(target){if (target.tagName=="IMG") { var para1 = document.getElementById("para1"); para1.setAttribute("class", "pp"); }} // content type <--No comma following the very last parameter, always! })</script>
TStamper
Thats exactly how it's now formatted at http://seacliffmm.com/test/tr-lights/Untitled-4.html, and still no joy. And the scrolling function does not work anymore, which is also a problem. Sorry.
Caron
@Caron- you need to start paying attention to the errors that the status shows, its says stepcarousel is null or not an object- meaning it is not detecting you file..so that is the reason your code is not working.correct that then try again
TStamper
Well, I don't know how to do that. Cleary, I'm way out of my depth. Thanks again very much for all your help.
Caron
try this one more change- change this line `<script src="js/stepcarousel.js"></script>` to this `<script type="text/javascript" src="stepcarousel.js"></script>`
TStamper
and also those stepcarouself files you downloaded, you have to make sure that script line is calling from the right directory, otherwise your script won't know what you're referring to which is why you're receiving that error. that part was working earlier so retrace your steps
TStamper
matter fact you can tell your script is not seeing your external files, since your arrow images are not there also. so you need to make sure you didnt move any folders around or file naming to what was earlier
TStamper
I will try that AND check all the calls in the files tomorrow when I'm back at work. Thank you.
Caron