Hanna
Hanna

Reputation: 10763

JQuery namespace/code acting funny

First off, here is my jsfiddle.

I have two click listeners. One on a Next button and one on a Back button. The listener on the Back button works great, but the one on the Nextbutton does not, despite them being in the same area of code.

The line of code in question is:

wizard.goTo($('#wizard-pages span[class="selected"]').next().index());

Strangely enough, if I run:

$('#wizard-pages span[class="selected"]').next().index();

I get the right index value. Also, if I run,

wizard.goTo(x);

(x being whatever number). I get the right page back.

It's only when they are combined that it does not work.

I've also tried making the parameter a variable and then passing it through but I get the same results. I also tried adding (+1) to the index, rather than calling .next() before it. Any ideas?

Upvotes: 0

Views: 60

Answers (1)

tymeJV
tymeJV

Reputation: 104775

Here's an updated fiddle: http://jsfiddle.net/7v8Xx/1/

You werent going far enough ahead in this line:

wizard.goTo($('#wizard-pages span[class="selected"]').next().index());

Add 1 to the index!!

wizard.goTo($('#wizard-pages span[class="selected"]').next().index()+1);

Upvotes: 3

Related Questions