Skip to content

Commit 103324d

Browse files
authored
Merge pull request #18 from zitudu/fix/index
fix: step index where step selectors not sibling
2 parents 4d0cd9f + 44b1f73 commit 103324d

File tree

4 files changed

+16
-10
lines changed

4 files changed

+16
-10
lines changed

dist/jquery-steps.js

Lines changed: 7 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery-steps.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/jquery-steps.min.js

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Steps.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,10 @@ class Steps {
1919

2020
stepClick(e) {
2121
e.preventDefault();
22-
const nextStep = $(this).closest('[data-step-target]').index();
22+
const { self } = e.data;
23+
const all = self.el.find(self.stepSelector);
24+
const next = $(this).closest('[data-step-target]');
25+
const nextStep = all.index(next);
2326
const stepIndex = e.data.self.getStepIndex();
2427
e.data.self.setActiveStep(stepIndex, nextStep);
2528
}
@@ -67,9 +70,8 @@ class Steps {
6770
}
6871

6972
getStepIndex() {
70-
const stepIndex = this.el.find(this.stepSelector)
71-
.filter(`.${this.options.activeClass.split(' ').join('.')}`)
72-
.index();
73+
const all = this.el.find(this.stepSelector);
74+
const stepIndex = all.index(all.filter(`.${this.options.activeClass.split(' ').join('.')}`));
7375
return stepIndex || 0;
7476
}
7577

0 commit comments

Comments
 (0)