Insert Script Tag In Durandal
I am a bit struggling with what should be an easy task. I want to insert a script tag inside a div tag. The problem is that Durandal (for a reason that I still need to understand)
Solution 1:
Ok, here's what I do to get this to work. Inside the parent tag, I use a compose binding like so:
<td><!-- ko compose: { view: 'views/homearea', model: 'viewmodels/homearea' } --><!-- /ko--></td>
Inside my view, I have something like this:
<div id="homearea" style="height: 400px; width: 400px;">
</div>
And inside the model, in the viewAttached method, I can put my custom javascript.
define(function () {
var viewAttached = function () {
$('#homearea').myFunction();
};
var vm = {
viewAttached: viewAttached
};
return vm;
});
Post a Comment for "Insert Script Tag In Durandal"