question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

How to run instance.getRawValue(), please?

See original GitHub issue

How to do this via valHooks, please? Basically each instance only applies to one input field, so you can run instance.getRawValue() to get raw value for specific input field.

_Originally posted by @nosir in https://github.com/nosir/cleave.js/issues/138#issuecomment-271559949_

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:6

github_iconTop GitHub Comments

1reaction
xIDMONxcommented, Apr 3, 2019

How to do this via valHooks, please? Basically each instance only applies to one input field, so you can run instance.getRawValue() to get raw value for specific input field.

Originally posted by @nosir in #138 (comment)

$('.superficie').toArray().forEach(function (field) {
            let cleave = new Cleave(field, {
                numeral:                    true,
                numeralPositiveOnly:        true,
                numeralThousandsGroupStyle: 'thousand'
            });
            
            $.valHooks[`#${$(field).attr('id')}`] = {
                get: function (el) {
                    return cleave.getRawValue();
                },
                set: function (el, val) {
                    $(el).html(val);
                }
            };
        });

$.valHooks["#txtSuperficieConstruida"].get()
"132654"
0reactions
xIDMONxcommented, Jul 5, 2021

Hi @muzaman, try the following:


$.valHooks[`#${ $( field ).attr( 'id' ) }`] = {
    get: function ( el ) {
        return cleave.getRawValue();
    },
    set: function ( val ) {
        cleave.setRawValue( el );
    }
}

$.valHooks["#id_price"].set(123456);

I hope and it works for you

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get Unique FormGroup/Control Value Without Using ...
I only want the values that would be present in .value , but I want a unique instance returned like getRawValue() .
Read more >
Karma Testing a FormGroup Instance: how to pass one in
Dynamically pass in ReactiveForm values with FormBuilder with Karma to test your Angular Application.
Read more >
Angular Reactive Forms: Tips and Tricks | by Netanel Basal
In order to get the complete form's values, we can use the FormGroup.getRawValue() method. Control Getters and Setters. I want to talk about...
Read more >
What's new in Angular 14 | InterSystems Developer Community
❗ Note that if you use nonNullable FormBuilder or if you set nonNullable option in FormControl, then when you call .reset() method it...
Read more >
Angular FormArray - Complete Guide
We are going to give an example of a common use case that would be ... to be inside the FormArray instance, built...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found