#newb1
1 messages · Page 1 of 1 (latest)
hi! do you have more context?
probably the most important context is i don't know what i'm doing as a preface
i assumed this would go after card mount is completed
what i want is autofocus, seems not possible
docs seem indicate event listener is required, not sure how to do that with cardElement.focus();
what part specifically are you struggling with, what have you tried?
here's an example. https://jsfiddle.net/a8m0db32/
that shows " card.focus();", that's not what's in the docs
why does card.focus(); work if the docs say to use cardElement.focus();
it's the same thing
it's a variable name, I called it card, the docs called it cardElement I could have called it pineapple
it's whatever you assign to the left side of x = elements.create('card' ...)
will try that then, thanks
didn't work
var card = elements.create('card', {style: style});
card.mount($cardElement[0]);
card.focus();
i assume i'm doing it wrong
maybe wait for it to have mounted and finished before calling it.
card.on('ready', function(event) {
card.focus()
})
tried that like so:
var card = elements.create('card', {style: style});
card.mount($cardElement[0]);
card.mount('#card-element');
card.on('ready', function(event) {
card.focus()
});
is this correct?
(didn't work)
worked for me
do you have a full example?
https://jsfiddle.net/f70Lagqe/ for example works fine for me
oh heck hang on, did it on the wrong page
so didn't work but
the code is from a form called quform
with a stripe integration instruction
(works fine)
but the focus line you're adding is after a line that is different
theirs is
var card = elements.create('card', {style: style});
card.mount($cardElement[0]);
while yours is
card.mount('#card-element');
card.on('ready', function(event) {
card.focus()
})
the mount lines are different
i'm guessing that's what's preventing focus from happening as expected?
if you want to see the full code example it's on their page https://support.themecatcher.net/quform-wordpress-v2/guides/advanced/stripe
the code I wrote is equivalent
I'd suggest reaching out to the maintainer of that wordpress plugin for help really since they are the developer here closely working with the Stripe integration
ok thanks