I'm using Nial Doherty's coda-slider plugin (http://plugins.jquery.com/
project/Coda-Slider), and trying to tweak it.

I'm creating several instances of the slider on a page. I'd like to
replicate the function of the 'previous' and 'next' buttons, but
inside the content panels themselves.


The code in coda-slider.1.1.1.js contains the following (for the
'previous' button):

jQuery(this).before('<div class="stripNavL" id="stripNavL' + j + '"><a
href="#"><img src="/img/left_arrow.png" class="rollover" alt="Left"
width="20" height="26" border="0" /></a></div>');

jQuery("div#stripNavL" + j + " a").click(function(){
        this.blur();
        if (cPanel == 1) {
                var cnt = - (panelWidth*(panelCount - 1));
                cPanel = panelCount;
        } else {
                cPanel -= 1;
                var cnt = - (panelWidth*(cPanel - 1));
        };
        
jQuery(this).parent().parent().find("div.panelContainer").animate({ left:
cnt}, settings.easeTime, settings.easeFunc);
        Change the URL hash (cross-linking)...
        location.hash = cPanel;
        return false;
});

That seems pretty simple to me. I thought I could replicate it by
duplicating it for all my 'previous' buttons in the various sliders,
so I added this:

jQuery("a.inner_prev_version").click(function(){
        if (cPanel == 1) {
                var cnt = - (panelWidth*(panelCount - 1));
                cPanel = panelCount;
        } else {
                cPanel -= 1;
                var cnt = - (panelWidth*(cPanel - 1));
        };
        
jQuery(this).parent().parent().parent().parent().parent().parent().find("div.panelContainer").animate({
 left:
cnt}, settings.easeTime, settings.easeFunc);
        return false;
});

Which adds the same functionality to all links in the actual panel
contents. Except it's not. What's happening is that it seems to be
calling the animation effect multiple times - I click a link, and the
panel goes flying off to God knows where.
One thing I'm suspicious of is my use of so many parent() calls to
work my way back up to the slider-wrap div. In the original click
handlers, I added:
        console.log(jQuery(this).parent().parent());
and it logs one element.
But in my new click handlers, if I log the same:
        
console.log(jQuery(this).parent().parent().parent().parent().parent().parent());
then twelve log entries show up, all logging a slider-wrap div
element.

Clearly this is a bit complicated, and thankyou for getting this far.
I don't expect a solution - there could be so many possible causes -
but any advice would be hugely appreciated....

Cheers.



Reply via email to