I'm passing a javascript function through the application.js in ruby on rails it work in the fisrt view but when I change to another view it doesn't load, just stay blank
this is the
application.js
:
//= require rails-ujs
//= require jquery
//= require turbolinks
//= require owl.carousel
//= require jquery.lazyload
//= require tinymce-jquery
//= require activestorage
//= require_tree .
function addView(){
atOptions = {
'key' : 'xxxxxxxxxxxxxxxxxxxxx',
'format' : 'iframe',
'height' : 250,
'width' : 300,
'params' : {}
};
document.write('<scr' + 'ipt type="text/javascript" src="http' + (location.protocol === 'https:' ? 's' : '') + '://www.bcloudhost.com/ecd09eb0e13224fce209c614c8e4ea98/invoke.js"></scr' + 'ipt>');
}
then I call this function in partial view like this: _article.html.erb
<div class="side">
<script type="text/javascript">
addView();
</script>
</div>
this is the message that I got from the console
Uncaught DOMException: Failed to execute 'removeChild' on 'Node': The node to be removed is not a child of this node.
I will really appreciate if you can help with this issue.