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

Refreshing the Credit Card Image #471

Open
dcipher opened this issue Sep 24, 2020 · 9 comments
Open

Refreshing the Credit Card Image #471

dcipher opened this issue Sep 24, 2020 · 9 comments
Labels
workaround A workaround has been provided

Comments

@dcipher
Copy link

dcipher commented Sep 24, 2020

I have the masked Credit Card No (**** **** **** 1234), expiry and Name stored on a cell phone. When the user wants to update their credit card information it would be nice if the form showed the currently saved values without having the user enter data in each field. So is there a way to cause the form to refresh using the values in the pre-loaded fields?

@sergeykonovalenko
Copy link

I have the same problem

@melloware
Copy link
Collaborator

melloware commented Dec 21, 2020

I use JQuery and this works for me to show the card with the values that are prefilled updated.

$(document).ready(function() {
    const blur = new Event('blur');
    const change = new Event('change');
    $('form').find(':input').each(function() {
        if (this.name === "number" || this.name === "name" || this.name === "expiry" || this.name === "cvc") {
            this.dispatchEvent(blur);
            this.dispatchEvent(change);
        }
    })
});

This assumes your field names are like mine above. Works like a charm

@ronaldohoch
Copy link

Same here.
But, used the solution provided by melloware.

Angular code:
this.nameInput.nativeElement.dispatchEvent(new Event('change'));

But, when set the input to empty, this doesn't work, tried these events: change, keydown, keyup, blur, keypress.

@melloware
Copy link
Collaborator

@ronaldohoch and you are using the latest version found in the /dist folder here? Just making sure its not already fixed as we have committed some fixes since the 2.5.0 release that is on NPM.

@melloware
Copy link
Collaborator

Also I think I had to fire BOTH blur and change to make it work.

@ronaldohoch
Copy link

Due Content Security Policy, i need to download the file '-'
Is this the new version?

https://unpkg.com/card@2.5.0/dist/card.js

@melloware
Copy link
Collaborator

No this 2.5.1 is not published to NPM yet: https://github.com/jessepollak/card/tree/master/dist

@melloware
Copy link
Collaborator

You can see what has been fixed in 2.5.1 here: https://github.com/jessepollak/card/milestone/2?closed=1

@ronaldohoch
Copy link

Worked!

Thank you :)

@melloware melloware added the workaround A workaround has been provided label Feb 1, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
workaround A workaround has been provided
Projects
None yet
Development

No branches or pull requests

5 participants
@dcipher @ronaldohoch @melloware @sergeykonovalenko and others