How to conditionally load javascript files based on tab toggled?How to unload a javascript from an html?Multiple Stripe payment forms on single pageHow to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?

Feasibility of lava beings?

Which sphere is fastest?

Why would a military not separate its forces into different branches?

Adding command shortcuts to /bin

Copy previous line to current line from text file

Expected Waiting Time in a Queue with exponential distribution

Why is my arithmetic with a long long int behaving this way?

How do I, as a DM, handle a party that decides to set up an ambush in a dungeon?

Is there an age requirement to play in Adventurers League?

How do LIGO and VIRGO know that a gravitational wave has its origin in a neutron star or a black hole?

Why didn't this character get a funeral at the end of Avengers: Endgame?

Nested loops to process groups of pictures

Are pressure-treated posts that have been submerged for a few days ruined?

Why does sound not move through a wall?

Dangerous workplace travelling

How does the reduce() method work in Java 8?

Should I mention being denied entry to UK due to a confusion in my Visa and Ticket bookings?

Which US defense organization would respond to an invasion like this?

Is there precedent or are there procedures for a US president refusing to concede to an electoral defeat?

Why do people keep telling me that I am a bad photographer?

Is disk brake effectiveness mitigated by tyres losing traction under strong braking?

What do I do if my advisor made a mistake?

Is “snitty” a popular American English term? What is its origin?

Has a commercial or military jet bi-plane ever been manufactured?



How to conditionally load javascript files based on tab toggled?


How to unload a javascript from an html?Multiple Stripe payment forms on single pageHow to validate an email address in JavaScript?How do JavaScript closures work?How do I remove a property from a JavaScript object?How do you get a timestamp in JavaScript?How do I check if an array includes an object in JavaScript?How do I copy to the clipboard in JavaScript?How do I include a JavaScript file in another JavaScript file?How to replace all occurrences of a string in JavaScriptHow to check whether a string contains a substring in JavaScript?How do I remove a particular element from an array in JavaScript?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I want, depending on the radio selected, for the javascript associated with the radio to function, and when its not selected or deselected, to not be functioning.



HTML for tabs and radios:



<nav>
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
<a class="nav-item nav-link active no-decoration" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Video</a>
<a class="nav-item nav-link no-decoration" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Tweet</a>
</div>
</nav>
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">

<div class="card-body">
CHOOSE RADIO

<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio in active">
<input type="radio" name="distTravel" value="Ontario" class=" no-decoration" data-id="onlyON" />
<span class="custom-control-indicatore"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel" value="NA" class=" no-decoration" data-id="onlyNA" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content in active">
<div class="card-block tab-pane active" id="onlyON">
TEXT
</div>

<span class="token"></span>
<% end %>
<% end %>
</div>
<div class="card-block tab-pane" id="onlyNA">

</div>

</div>
</div>

</div>
</div>
<div class="tab-pane-1 fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<div class="card-body">

CHOOSE RADIO
<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="Ontario-2" class="no-decoration" data-id="onlyON-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="NA-2" class="no-decoration" data-id="onlyNA-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content-2 in active">
<div class="card-block tab-pane-1 active" id="onlyON-1">

TEXT
</div>

<span class="token"></span>

<div class="card-block tab-pane-1" id="onlyNA-1">
</div>
<% end %>
<% end %>
</div>
</div>
</div>


Javascript tags:



<%= javascript_include_tag "stripe" %>
<%= javascript_include_tag "stripe-a" %>
<%= javascript_include_tag "stripe-2" %>
<%= javascript_include_tag "stripe-2-a" %>


For example:



If radio [data-id="onlyON"] is selected, then <%= javascript_include_tag "stripe" %> will be be loaded. Then, when [data-id="onlyON-1"] is selected, <%= javascript_include_tag "stripe" %> will unload, and <%= javascript_include_tag "stripe-a" %> will load so on and so fourtha










share|improve this question
























  • I could be wrong, but I don't think that is how things work.

    – jvillian
    Mar 23 at 2:31











  • Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

    – uno
    Mar 23 at 2:36






  • 1





    I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

    – uno
    Mar 23 at 3:40











  • What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

    – lacostenycoder
    Mar 23 at 17:16











  • Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

    – uno
    Mar 23 at 19:38

















0















I want, depending on the radio selected, for the javascript associated with the radio to function, and when its not selected or deselected, to not be functioning.



HTML for tabs and radios:



<nav>
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
<a class="nav-item nav-link active no-decoration" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Video</a>
<a class="nav-item nav-link no-decoration" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Tweet</a>
</div>
</nav>
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">

<div class="card-body">
CHOOSE RADIO

<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio in active">
<input type="radio" name="distTravel" value="Ontario" class=" no-decoration" data-id="onlyON" />
<span class="custom-control-indicatore"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel" value="NA" class=" no-decoration" data-id="onlyNA" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content in active">
<div class="card-block tab-pane active" id="onlyON">
TEXT
</div>

<span class="token"></span>
<% end %>
<% end %>
</div>
<div class="card-block tab-pane" id="onlyNA">

</div>

</div>
</div>

</div>
</div>
<div class="tab-pane-1 fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<div class="card-body">

CHOOSE RADIO
<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="Ontario-2" class="no-decoration" data-id="onlyON-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="NA-2" class="no-decoration" data-id="onlyNA-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content-2 in active">
<div class="card-block tab-pane-1 active" id="onlyON-1">

TEXT
</div>

<span class="token"></span>

<div class="card-block tab-pane-1" id="onlyNA-1">
</div>
<% end %>
<% end %>
</div>
</div>
</div>


Javascript tags:



<%= javascript_include_tag "stripe" %>
<%= javascript_include_tag "stripe-a" %>
<%= javascript_include_tag "stripe-2" %>
<%= javascript_include_tag "stripe-2-a" %>


For example:



If radio [data-id="onlyON"] is selected, then <%= javascript_include_tag "stripe" %> will be be loaded. Then, when [data-id="onlyON-1"] is selected, <%= javascript_include_tag "stripe" %> will unload, and <%= javascript_include_tag "stripe-a" %> will load so on and so fourtha










share|improve this question
























  • I could be wrong, but I don't think that is how things work.

    – jvillian
    Mar 23 at 2:31











  • Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

    – uno
    Mar 23 at 2:36






  • 1





    I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

    – uno
    Mar 23 at 3:40











  • What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

    – lacostenycoder
    Mar 23 at 17:16











  • Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

    – uno
    Mar 23 at 19:38













0












0








0








I want, depending on the radio selected, for the javascript associated with the radio to function, and when its not selected or deselected, to not be functioning.



HTML for tabs and radios:



<nav>
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
<a class="nav-item nav-link active no-decoration" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Video</a>
<a class="nav-item nav-link no-decoration" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Tweet</a>
</div>
</nav>
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">

<div class="card-body">
CHOOSE RADIO

<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio in active">
<input type="radio" name="distTravel" value="Ontario" class=" no-decoration" data-id="onlyON" />
<span class="custom-control-indicatore"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel" value="NA" class=" no-decoration" data-id="onlyNA" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content in active">
<div class="card-block tab-pane active" id="onlyON">
TEXT
</div>

<span class="token"></span>
<% end %>
<% end %>
</div>
<div class="card-block tab-pane" id="onlyNA">

</div>

</div>
</div>

</div>
</div>
<div class="tab-pane-1 fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<div class="card-body">

CHOOSE RADIO
<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="Ontario-2" class="no-decoration" data-id="onlyON-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="NA-2" class="no-decoration" data-id="onlyNA-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content-2 in active">
<div class="card-block tab-pane-1 active" id="onlyON-1">

TEXT
</div>

<span class="token"></span>

<div class="card-block tab-pane-1" id="onlyNA-1">
</div>
<% end %>
<% end %>
</div>
</div>
</div>


Javascript tags:



<%= javascript_include_tag "stripe" %>
<%= javascript_include_tag "stripe-a" %>
<%= javascript_include_tag "stripe-2" %>
<%= javascript_include_tag "stripe-2-a" %>


For example:



If radio [data-id="onlyON"] is selected, then <%= javascript_include_tag "stripe" %> will be be loaded. Then, when [data-id="onlyON-1"] is selected, <%= javascript_include_tag "stripe" %> will unload, and <%= javascript_include_tag "stripe-a" %> will load so on and so fourtha










share|improve this question
















I want, depending on the radio selected, for the javascript associated with the radio to function, and when its not selected or deselected, to not be functioning.



HTML for tabs and radios:



<nav>
<div class="nav nav-tabs nav-fill" id="nav-tab" role="tablist">
<a class="nav-item nav-link active no-decoration" id="nav-home-tab" data-toggle="tab" href="#nav-home" role="tab" aria-controls="nav-home" aria-selected="true">Video</a>
<a class="nav-item nav-link no-decoration" id="nav-profile-tab" data-toggle="tab" href="#nav-profile" role="tab" aria-controls="nav-profile" aria-selected="false">Tweet</a>
</div>
</nav>
<div class="tab-content py-3 px-3 px-sm-0" id="nav-tabContent">
<div class="tab-pane fade show active" id="nav-home" role="tabpanel" aria-labelledby="nav-home-tab">

<div class="card-body">
CHOOSE RADIO

<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio in active">
<input type="radio" name="distTravel" value="Ontario" class=" no-decoration" data-id="onlyON" />
<span class="custom-control-indicatore"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel" value="NA" class=" no-decoration" data-id="onlyNA" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content in active">
<div class="card-block tab-pane active" id="onlyON">
TEXT
</div>

<span class="token"></span>
<% end %>
<% end %>
</div>
<div class="card-block tab-pane" id="onlyNA">

</div>

</div>
</div>

</div>
</div>
<div class="tab-pane-1 fade" id="nav-profile" role="tabpanel" aria-labelledby="nav-profile-tab">
<div class="card-body">

CHOOSE RADIO
<form id="selectForm">
<ul class="nav flex-column">
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="Ontario-2" class="no-decoration" data-id="onlyON-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">You</span>
</label>
</li>
<li class="nav-item">
<label class="custom-control custom-radio">
<input type="radio" name="distTravel-2" value="NA-2" class="no-decoration" data-id="onlyNA-1" />
<span class="custom-control-indicator"></span>
<span class="custom-control-description">Someone else</span>
</label>
</li>
</ul>
</form>

<div class="tab-content-2 in active">
<div class="card-block tab-pane-1 active" id="onlyON-1">

TEXT
</div>

<span class="token"></span>

<div class="card-block tab-pane-1" id="onlyNA-1">
</div>
<% end %>
<% end %>
</div>
</div>
</div>


Javascript tags:



<%= javascript_include_tag "stripe" %>
<%= javascript_include_tag "stripe-a" %>
<%= javascript_include_tag "stripe-2" %>
<%= javascript_include_tag "stripe-2-a" %>


For example:



If radio [data-id="onlyON"] is selected, then <%= javascript_include_tag "stripe" %> will be be loaded. Then, when [data-id="onlyON-1"] is selected, <%= javascript_include_tag "stripe" %> will unload, and <%= javascript_include_tag "stripe-a" %> will load so on and so fourtha







javascript ruby-on-rails ruby






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 23 at 6:29









ChrisBrownie55

2,0071823




2,0071823










asked Mar 23 at 1:30









unouno

34819




34819












  • I could be wrong, but I don't think that is how things work.

    – jvillian
    Mar 23 at 2:31











  • Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

    – uno
    Mar 23 at 2:36






  • 1





    I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

    – uno
    Mar 23 at 3:40











  • What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

    – lacostenycoder
    Mar 23 at 17:16











  • Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

    – uno
    Mar 23 at 19:38

















  • I could be wrong, but I don't think that is how things work.

    – jvillian
    Mar 23 at 2:31











  • Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

    – uno
    Mar 23 at 2:36






  • 1





    I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

    – uno
    Mar 23 at 3:40











  • What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

    – lacostenycoder
    Mar 23 at 17:16











  • Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

    – uno
    Mar 23 at 19:38
















I could be wrong, but I don't think that is how things work.

– jvillian
Mar 23 at 2:31





I could be wrong, but I don't think that is how things work.

– jvillian
Mar 23 at 2:31













Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

– uno
Mar 23 at 2:36





Hm. Well my issue is that I have multiple stripe forms on one page and each gets displayed via the tabs. I then have a stripe.js file paired to each individual stripe form. In testing this works, but when in live, I am unable to enter a credit card number because it will tell me the CC field isn't filled since the other stripe.js files are being loaded. When i use only one stripe.js file, it will work (in relation to the form being used). I will post the stripe.js file in case you have any ideas on how to load them and maybe have the js have some sort of blanket over all of the forms

– uno
Mar 23 at 2:36




1




1





I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

– uno
Mar 23 at 3:40





I figured out the issue. due to calling the similar javascript files, and or multiple post forms, it only wants to POST the last form on the page. So i need to somehow, similar to my OP, dynamically have all of the forms on one page with some sort of way to combine them

– uno
Mar 23 at 3:40













What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

– lacostenycoder
Mar 23 at 17:16





What is the purpose of "Multiple stripes" on a single page? Surely there is a better way to do this.

– lacostenycoder
Mar 23 at 17:16













Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

– uno
Mar 23 at 19:38





Because there are variables and no cart. Everything needs to be done on one page for convenience. It;s doable, I just don't know how to do it. I'm sure someone who knows JS a lot could look at this and know what to do in 30 seconds

– uno
Mar 23 at 19:38












2 Answers
2






active

oldest

votes


















0














There's no easy way to unload/disable a script tag once it's added to a document; especially when it's a third-party script like Stripe, and not a script you can easily edit yourself.



Instead, I'd break the problem into multiple documents. If the body of each tab includes an iframe, and each iframe contains a Stripe JS file and the form components it cares about, you'll have isolated each Stripe script to its own document and they shouldn't interfere with each other.






share|improve this answer























  • What exactly do you mean by document? Can you put up a small piece to show me?

    – uno
    Mar 23 at 19:38











  • I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

    – uno
    Mar 23 at 19:56


















0














I surrounded the js stripe code with click functions. works. when a radio or tab is clicked (depending on form navigation) the js code will "toggle" on. it works when going back and fourth between function toggles as well.



All solved now and haven't had issues from my tests






share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function ()
    StackExchange.using("externalEditor", function ()
    StackExchange.using("snippets", function ()
    StackExchange.snippets.init();
    );
    );
    , "code-snippets");

    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "1"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    autoActivateHeartbeat: false,
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader:
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    ,
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );













    draft saved

    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55309766%2fhow-to-conditionally-load-javascript-files-based-on-tab-toggled%23new-answer', 'question_page');

    );

    Post as a guest















    Required, but never shown

























    2 Answers
    2






    active

    oldest

    votes








    2 Answers
    2






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    There's no easy way to unload/disable a script tag once it's added to a document; especially when it's a third-party script like Stripe, and not a script you can easily edit yourself.



    Instead, I'd break the problem into multiple documents. If the body of each tab includes an iframe, and each iframe contains a Stripe JS file and the form components it cares about, you'll have isolated each Stripe script to its own document and they shouldn't interfere with each other.






    share|improve this answer























    • What exactly do you mean by document? Can you put up a small piece to show me?

      – uno
      Mar 23 at 19:38











    • I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

      – uno
      Mar 23 at 19:56















    0














    There's no easy way to unload/disable a script tag once it's added to a document; especially when it's a third-party script like Stripe, and not a script you can easily edit yourself.



    Instead, I'd break the problem into multiple documents. If the body of each tab includes an iframe, and each iframe contains a Stripe JS file and the form components it cares about, you'll have isolated each Stripe script to its own document and they shouldn't interfere with each other.






    share|improve this answer























    • What exactly do you mean by document? Can you put up a small piece to show me?

      – uno
      Mar 23 at 19:38











    • I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

      – uno
      Mar 23 at 19:56













    0












    0








    0







    There's no easy way to unload/disable a script tag once it's added to a document; especially when it's a third-party script like Stripe, and not a script you can easily edit yourself.



    Instead, I'd break the problem into multiple documents. If the body of each tab includes an iframe, and each iframe contains a Stripe JS file and the form components it cares about, you'll have isolated each Stripe script to its own document and they shouldn't interfere with each other.






    share|improve this answer













    There's no easy way to unload/disable a script tag once it's added to a document; especially when it's a third-party script like Stripe, and not a script you can easily edit yourself.



    Instead, I'd break the problem into multiple documents. If the body of each tab includes an iframe, and each iframe contains a Stripe JS file and the form components it cares about, you'll have isolated each Stripe script to its own document and they shouldn't interfere with each other.







    share|improve this answer












    share|improve this answer



    share|improve this answer










    answered Mar 23 at 16:24









    Brad BuchananBrad Buchanan

    832819




    832819












    • What exactly do you mean by document? Can you put up a small piece to show me?

      – uno
      Mar 23 at 19:38











    • I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

      – uno
      Mar 23 at 19:56

















    • What exactly do you mean by document? Can you put up a small piece to show me?

      – uno
      Mar 23 at 19:38











    • I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

      – uno
      Mar 23 at 19:56
















    What exactly do you mean by document? Can you put up a small piece to show me?

    – uno
    Mar 23 at 19:38





    What exactly do you mean by document? Can you put up a small piece to show me?

    – uno
    Mar 23 at 19:38













    I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

    – uno
    Mar 23 at 19:56





    I found this... any thoughts on it? stackoverflow.com/questions/38826091/…

    – uno
    Mar 23 at 19:56













    0














    I surrounded the js stripe code with click functions. works. when a radio or tab is clicked (depending on form navigation) the js code will "toggle" on. it works when going back and fourth between function toggles as well.



    All solved now and haven't had issues from my tests






    share|improve this answer



























      0














      I surrounded the js stripe code with click functions. works. when a radio or tab is clicked (depending on form navigation) the js code will "toggle" on. it works when going back and fourth between function toggles as well.



      All solved now and haven't had issues from my tests






      share|improve this answer

























        0












        0








        0







        I surrounded the js stripe code with click functions. works. when a radio or tab is clicked (depending on form navigation) the js code will "toggle" on. it works when going back and fourth between function toggles as well.



        All solved now and haven't had issues from my tests






        share|improve this answer













        I surrounded the js stripe code with click functions. works. when a radio or tab is clicked (depending on form navigation) the js code will "toggle" on. it works when going back and fourth between function toggles as well.



        All solved now and haven't had issues from my tests







        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Mar 29 at 23:18









        unouno

        34819




        34819



























            draft saved

            draft discarded
















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid


            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.

            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55309766%2fhow-to-conditionally-load-javascript-files-based-on-tab-toggled%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

            SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

            은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현