jquery - How to reload external JavaScript library without reloading page -
i included viostream api js library on head
of project, can use object viostreamplayer
in js file:
<head> ... <script src='https://publish.viostream.com/embed/api'></script> </head>
i need call embed
function twice in js , without reloading page. however, second time use viostreamplayer
cause problem.
therefore, reload api library before second use. make sure viostreamplayer
object fresh , ready use.
more details:
i use backbone.js
load video view in page, , after video view loaded js, should update video content. that's why need call embed
function twice, load video. new video embedded, event handler failed. load page js cannot reload head
.
the event handler added calling on
method viostreamplayer
:
viostreamplayer.on('play', function(){})
but out of work when embedded second video. that's why looking method make sure viostreamplayer
fresh before calling embed
function.
documentation: https://help.viostream.com/hc/en-us/articles/223291607-embedding-and-using-the-player-api
cheers
update
viostreamplayer has updated api error no longer existing.
if using jquery can use $.getscript()
reload.
example:
settimeout(() => { $.getscript("https://publish.viostream.com/embed/api?1") .done(function (script, textstatus) { console.log(textstatus); }) .fail(function (jqxhr, settings, exception) { console.log.("triggered ajaxerror handler."); }); }, 1000);
Comments
Post a Comment