0

I have a Durandal App.

On one of the pages, I need to using some existing javascript which I do not want to modify.

However, if I use something like this in the view.html:

<script>alert("test");</script>

the alert is not triggered.

Normally such code would go into the ViewModel. However, in this case, I want to use a Sound Recorder and there is a number of scripts that make this up and I would like to use them as is.

In other words, I would like view.html to act like a regular html page.

When I modify the router to use *.html, it throws an error.

{ route: 'recorder', moduleId: 'views/recorder.html', nav: true }

Is there a way to resolve this?

Greg Gum
  • 33,478
  • 39
  • 162
  • 233
  • According to Rob Eiserberg (the author of Durandal), don't do [this](https://groups.google.com/forum/#!topic/durandaljs/18NQHqK8i20). Additionally, you could implement the solution recommended [here](http://stackoverflow.com/questions/17640856/running-javascript-inside-durandal-view). – Brett Jun 15 '15 at 16:09

1 Answers1

1

Taking the recommendation from the OP and posting my comment as an answer:

According to Rob Eiserberg (the author of Durandal), don't do this. The reason being is that all script tags within the view are stripped. I'm sure this is done as a security precaution. Additionally, you could implement the solution recommended here.

Community
  • 1
  • 1
Brett
  • 4,268
  • 1
  • 13
  • 28