Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Persistent value after clearing values #11

Open
richbowen opened this issue Jul 13, 2017 · 8 comments
Open

Persistent value after clearing values #11

richbowen opened this issue Jul 13, 2017 · 8 comments

Comments

@richbowen
Copy link

When clearing the values of inputs, the cleave components retain the initial value in a variable called initValue.
screenshot from 2017-07-13 16-51-05

This shows the value retained by the component on the left where the normal input dialog on the right, after being cleared is empty:
screenshot from 2017-07-13 16-52-57

@alevans4
Copy link

@rgb-one you could submit a pull request with the fix we came up with.

@richbowen
Copy link
Author

richbowen commented Jul 13, 2017

Cool :); gonna go over the code some more so I can understand it better. Thanks @alevans4

@heribertusk
Copy link

sorry for bumping this issues, is this problem already solved? because I still can't clear values on input programmaticaly.

@richbowen
Copy link
Author

Haven't submitted a pull request.
Add this to the watch section of the component:

watch: {
    // ...
    value(val) {
      this.cleave.setRawValue(val)
    }
  }

@KyleXie
Copy link

KyleXie commented Oct 14, 2017

@rgb-one your solution works, how about send a PR for this? Thanks.

@heribertusk
Copy link

@rgb-one : your solution works, but i'm using non-standar format for thousand separator. So I change it a bit:

watch: {
    // ...
    value(val) {
     this.cleave.setRawValue(val.replace(/\D/g,''))
    }
  }

Basically I remove all char and only keep number on string. Is this way correct too?

@richbowen
Copy link
Author

That seems like it would work, but I think adding such functionality would be better done using "Custom Options" provided by the Cleave package: Here's an example: https://jsfiddle.net/rgb1/LfLbvgrL/4/.

@ezerw
Copy link

ezerw commented Apr 28, 2018

I have it working with:

<cleave class="form-control" v-model="phone" ref="phone" :options="{...}">
...
clear(){
     this.$refs.phone.cleave.setRawValue(null);
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants