cleave.js
cleave.js copied to clipboard
As a user, I would like the lib to init multiple input fields automatically base on DOM selector
Originally posted by @iofacture in https://github.com/nosir/cleave.js/issues/209#issuecomment-483096858
I concur.
Super surprised this wasn't possible? For real though - why wouldn't you want to just give a number of inputs a class and run one function to initialize them?
The following actually worked just fine for me:
$('.dollar-amount').toArray().forEach(function (field) {
new Cleave(field, {
numeral: true,
prefix: '$'
});
});
solution works but real solution is it should be default behaviour if you're using a class selector.
class selector working on a single element is not good.