#rssv
1 messages · Page 1 of 1 (latest)
var card_num = elements.create('card');
card_num.mount('#card_num');
What do you mean by 'clears the parent'?
<div class="text-box-container 8l6kgi" id="card_num">
<input type="text" autocomplete="off" class="text-box svelte-8l6kgi" id="card" placeholder="Card number">
<div class="text-box-underline svelte-8l6kgi"></div>
<div class="text-box-buttons svelte-8l6kgi"></div>
</div> ```
Let's say this is the input I want to shown in payment form,
```<div class="text-box-container 8l6kgi" id="card_num"> <div class="text-box-underline svelte-8l6kgi"></div> <div class="text-box-buttons svelte-8l6kgi"></div></div>````
I set it up like this, but whenever I mount the input from JS
card_num.mount('#card_num');
It clears the inline elements
Are you using some kind of third-party Svelte lib for Stripe.js?
My website used to built with Svelte, but it's currently native js & html (dumped the website, class names remains same as svelte), so no.
I'd recommended looking at https://www.sveltestripe.com/
Everything you need to access Stripe payments with Svelte
Downloaded JS from website, examples -> custom-payment-flow -> html -> card
Stripe.js doesn't really work with these frameworks out of the box, and we don't have an official Svelte lib (only React)
Website is not Svelte anymore.
Like I said, I dumped the website after fully loaded, it's native JS
Then you'll need to provide me with a reproduction of the issue because I'm not fully understanding it
.appendChild appends an element to desired element
.innerHTML changes the html of desired element
I want to append stripe card number input into a div, but it's behaviour same as innerHTML
None of your code you shared includes that, hence why I've asked for a reproduction
document.getElementById('card_num').innerHTML = card_num;
document.getElementById('card_num').appendChild(card_num);
card_num.mount('#card_num');
This code behaves like innerHTML one, I want to use it as second one
Nevermind then, I can add the rest of HTML by myself
Yeah, not really sure what you're trying to do exactly but the Elements are pretty locked down and you can't really mutate them directly via JS