GithubHelp home page GithubHelp logo

Comments (10)

probil avatar probil commented on August 17, 2024

hmm... I will check. You are using v1.x (for vue-2.x), right?

from v-mask.

lucassmacedo avatar lucassmacedo commented on August 17, 2024

i`m using 2.x.. i want change by conditional..

<input type="radio" id="cpf" value="cpf" name="type"  v-on:change="onChange">
<input type="radio" id="cnpj" value="cnpj" name="type" v-on:change="onChange">

..
<input v-mask="maskDoc" type="text" name="doc" > ...

        data: function () {
            return {
                maskDoc = '###.###.###/###';
            }
        },

...

            onChange : function(e){
              var radio = e.srcElement;
              var value = radio.value;
                if(value  == 'cpf'){
                    this.maskDoc = '###.###.###/###';
                }else{
                    this.maskDoc = '###.###.#####/###-##';
                }
            }

....

from v-mask.

caioincau avatar caioincau commented on August 17, 2024

I am having the same problem on my job.

from v-mask.

caioincau avatar caioincau commented on August 17, 2024

Object.defineProperty(exports, "__esModule", {
  value: true
});

exports.default = function (Vue) {
  Vue.directive('mask', {
    bind: function bind(el, _ref2) {
      var value = _ref2.value;

      var handlerFunc = handler.bind({ format: value });
      el.addEventListener('input', handlerFunc, false);

      return handlerFunc({ target: el });
    },
    componentUpdated(el, {value,oldValue}){

      if(value !== oldValue){
        var elClone = el.cloneNode(true);
        el.parentNode.replaceChild(elClone, el);
        console.log("Old" + oldValue);
        console.log("value" + value);
        let handlerFunc = handler.bind({format: value});
        elClone.addEventListener('input', handlerFunc, false);
        return handlerFunc({target: elClone});
      }
    },
    unbind: function unbind(el) {
      el.removeEventListener('input', handler, false);
    }
  });
};

var _format = require('./format.js');

var _format2 = _interopRequireDefault(_format);

function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }

function handler(_ref) {
  var target = _ref.target;
  var previousValue = target.dataset.previousValue;

  if (typeof previousValue === 'string' && previousValue.length < target.value.length) {
    target.value = (0, _format2.default)(target.value, this.format);
  }

  target.dataset.previousValue = target.value;
}

;

from v-mask.

caioincau avatar caioincau commented on August 17, 2024

This is working for me

from v-mask.

probil avatar probil commented on August 17, 2024

@icaio Why you are changing compiled version?
BTW, this feature will be implemeted in the next release. It's already fixed

from v-mask.

caioincau avatar caioincau commented on August 17, 2024

Oh thanks :D

from v-mask.

probil avatar probil commented on August 17, 2024

@icaio , @lucassmacedo
Try latest master. I have already fixed it

from v-mask.

caioincau avatar caioincau commented on August 17, 2024

@probil the mask is working, but when you change the mask and type, the field lost focus and lost the previous value.

from v-mask.

probil avatar probil commented on August 17, 2024

@icaio Ok, the PureMask.js (the formatting function) is not "smart" enough to be able to parse old data with new mask. So, I'm going to use another lib or write my own. There is a lot of issues with PureMask.js

from v-mask.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.