Skip to content

Commit

Permalink
feat #113 (quantity selector): add jQueryInterface
Browse files Browse the repository at this point in the history
  • Loading branch information
MewenLeHo authored and julien-deramond committed Feb 24, 2022
1 parent bbe452a commit a89537a
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions js/src/quantity-selector.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,22 @@ class QuantitySelector extends BaseComponent {
btnUp.setAttribute('disabled', '')
}
}

static jQueryInterface(config) {
return this.each(function () {
const data = QuantitySelector.getOrCreateInstance(this, config)

if (typeof config !== 'string') {
return
}

if (typeof data[config] === 'undefined') {
throw new TypeError(`No method named "${config}"`)
}

data[config]()
})
}
}

/**
Expand Down

0 comments on commit a89537a

Please sign in to comment.