cleave.js icon indicating copy to clipboard operation
cleave.js copied to clipboard

As a user, I would like the lib to init multiple input fields automatically base on DOM selector

Open nosir opened this issue 5 years ago • 4 comments

Originally posted by @iofacture in https://github.com/nosir/cleave.js/issues/209#issuecomment-483096858

nosir avatar Jun 29 '19 16:06 nosir

I concur.

ianthedev avatar Jul 02 '19 01:07 ianthedev

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?

gregblass avatar Aug 20 '20 21:08 gregblass

The following actually worked just fine for me:

    $('.dollar-amount').toArray().forEach(function (field) {
        new Cleave(field, {
            numeral: true,
            prefix: '$'
        });
    });

gregblass avatar Aug 20 '20 21:08 gregblass

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.

gomedya avatar Jan 16 '21 13:01 gomedya