Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Script in Aureliaview not working

I am facing a strange issue with Aurelia view. I am using a script tag in one of my Aurelia view to integrate one of the external JavaScript file to my view. The script is not working on IE, and Firefox, but working fin with Chrome.

I found that the issue is not with the external script, rather any script tag within Aurelia view. Even the simple alert:

<template>
<script type="text/javascript">
    alert('Hi');      
</script>...

is not working with Firefox, whereas the same is working on Chrome.

Please let me know if I am missing anything.

EDIT : An alternative way to make this work is to use of attached() as described here.

like image 251
Sayan Pal Avatar asked Feb 04 '26 20:02

Sayan Pal


1 Answers

Proper way to inject <script> in Aurelia view is to use document.createElement('script'); in attached() like described here https://stackoverflow.com/a/36521405/4958643 or to make custom element like <script-injector> as described here http://www.sobell.net/calling-external-javascript-from-within-aurelia-templates/

like image 148
Nemanja Novicic Avatar answered Feb 06 '26 09:02

Nemanja Novicic



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!