I know there are better patterns but in this case there\'s some legacy code that we\'d like to move to a view. This html has a
If it's not already, you could wrap whatever is going on inside the script in a function (let's call it doBindings) and then embed the script in your index.html file (or equivalent), alongside Knockout, JQuery etc.
Then, in whatever view you need to get that code running in, add a viewAttached method to the view model and make the call to doBindings:
activate: function() {
...
}
viewAttached: function() {
doBindings();
}
That will invoke the function when the view is loaded and the DOM is accessible.
Solution here: Insert script tag in Durandal, but an answer here would have saved me some additional searching, so added here too.