2

I'm trying to implement Cleave.js with MooTools.js but although I'm doing it correctly (or so I believe, the implementation is very simple) I can't seem to get it to work no matter what.

I also tried testing in a website given by a contributor from the repository's issue tab.

The code is simple as well, I don't know if anyone knows what's the issue and there doesn't seem to be complains other than this other guy's issue which is similar to mine.

Code:

var CleavePhone = new Class({
    initialize: function()
    {
        window.addEvent('loadCleavePhonesFormatter', this.loadCleavePhonesFormatter);
        window.addEvent('loadCleavePhoneFormatter', this.loadCleavePhoneFormatter);

        return this.loadCleavePhonesFormatter();
    },
    loadCleavePhonesFormatter: function()
    {
        var elements = [];

        $$('input[cleave-type="phone"]').each(function(element){
            elements.push(new Cleave(element, {
                phone: true,
                phoneRegionCode: (element.get('cleave-country-code') || 'MX')
            }));
        });

        return elements;
    },
    loadCleavePhoneFormatter: function(element, country_code)
    {
        return new Cleave(element, {
            phone: true,
            phoneRegionCode: (country_code || 'MX')
        });
    }
});

Initialize — in some other part of global scripts (it is being imported and has no problem whatsoever):

new CleavePhone();
Richard Chambers
  • 16,643
  • 4
  • 81
  • 106
James
  • 679
  • 1
  • 8
  • 22

0 Answers0