card icon indicating copy to clipboard operation
card copied to clipboard

Add a destroy method

Open jvcunha opened this issue 8 years ago • 6 comments

There is a destroy method? How to use a modal, must destroy every hide the modal

jvcunha avatar Apr 12 '16 13:04 jvcunha

Thanks for opening this issue — I think this is a good idea! Ideally, this method would:

  • remove all event listeners
  • remove the initialized property
  • delete the card representation from inside the provided container

I think this would be a good issue for a new contributor to tackle. If no one wants to, I will look into it in the next couple weeks. Thanks again!

jessepollak avatar Apr 23 '16 20:04 jessepollak

Unfortunately, I don't possess the knowledge to do any of this or I would. Have you had a chance to work on this yet or is there a fast way to initialize to allow another card to be-entered? Thank you for your great work here, Jesse.

datamill2015 avatar Aug 10 '16 02:08 datamill2015

Any update on this? I'm using placeholders to show existing card info when showing edit_card route... The problem is when I go back to previous route and using the form in add_new_card route, the old placeholder is somehow displayed from previous edit_card route.

PS: I'm using React.

v3rron avatar Nov 07 '16 18:11 v3rron

Together with this, it needs an 'update' method. This is helpful if the form is changed by script after the card has been initialized.

princeofnaxos avatar Nov 14 '16 12:11 princeofnaxos

Hello, I needed to do something like this and I performed as follows, so far I have not detected any problems. I hope it helps. (using jQuery)

function resetCard(formSelector, containerSelector){

	$(containerSelector).html('').removeAttr('data-jp-card-initialized').unwrap('form');
	$(formSelector).removeData('card');

	$.each( $(formSelector+ ' input'), function(key, value){
		$(value).val('');
	});

	initCard(formSelector, containerSelector);
}

function initCard(formSelector, containerSelector)
{
	$(formSelector).card({
	    container: containerSelector,
	    placeholders: {
	        number: '•••• •••• •••• ••••',
	        name: "FULL NAME",
	        expiry: '••/••••',
	        cvc: '•••'
	    },
	    messages: {
	        validDate: "validate",
	        monthYear: 'mm/yyyy',
	    },
	    masks: {
	        cardNumber: '•'
	    }
	});
}

Rigolon avatar Apr 25 '17 14:04 Rigolon

I have the same problem. But, i solved this way, every time of need clear, reuse the modal, i execute this lines:

    $('div.jp-card')[0].className = 'jp-card jp-card-unknown';
    $("div.jp-card-number").text("•••• •••• •••• ••••");
    $("div.jp-card-name").text("FULL NAME");
    $("div.jp-card-expiry").text("••/••••");
    $("div.jp-card-cvc").text("•••");

marciobsilva avatar Sep 20 '18 17:09 marciobsilva