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.

Talk about features that would help Single Page Apps

See original GitHub issue

braintree-web’s design comes from a time when checkout flows generally used a <form> POST. This is no longer the case in 2015, where SPAs and JS-heavy checkout flows are common.

There are a couple things that keep braintree-web from working well in SPAs, the biggest of which is that braintree.setup can only be called once per page load.

I’m starting this thread to discuss what kinds of features would be useful for making braintree-web work better in JS-heavy checkout flows.

Related Issues:

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:93 (13 by maintainers)

github_iconTop GitHub Comments

1reaction
iokaravascommented, Jul 29, 2015

I ended up “solving” this by using an iframe. It might not seem clean but it works perfectly fine and there are no left-overs.

I’m creating a new iframe, injecting html that includes the form and script setup for braintree with the Client Token using javascript:window["content"] .

Then every callback of braintree’s drop-in (onPaymentReceived, onReady, onError) is handled by using Window.postMessage() on the main application window.

Every time you need to create a new drop-in with a different Client Token, you just remove the iframe, and re-create it. This is untested as far as older browsers go but it works perfectly fine on Firefox and Chrome.

Let me know what you think.

0reactions
kyledetellacommented, Nov 12, 2015

@parreirat glad to hear it helped out!

Also, good call on posting the documentation in this thread, that slipped my mind!

Read more comments on GitHub >

github_iconTop Results From Across the Web

What is Single Page Application? Pros and Cons with Examples
A single page application is easy to deploy compared to multi page application. Brands like Gmail and Facebook uses SPA. Know more about...
Read more >
Single-Page Apps: Advantages, Pitfalls, and Best-for ... - Apriorit
In this article, we discuss advantages and disadvantages of single-page applications as well as popular JavaScript frameworks for SPA ...
Read more >
Comprehensive Guide to Single Page Applications - HUSPI
In this article, we'll talk about what is Single Page Application (SPA), what benefits SPA brings to users and businesses, how it works...
Read more >
What Are Single Page Applications? Examples, Frameworks ...
Gmail, Facebook, Trello, Google Maps, etc., all are Single Page Applications that offer an outstanding user experience in the browser with no page...
Read more >
Key Benefits and Pitfalls of Single-Page and Multi-Page Apps
Multi-page apps can include as much information about products or services as required, with no page limitations. Single-page applications don't ...
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