In my Create View:
<script type="text/javascript">
var tabContent = "<% Html.RenderPartial("ProductEdit", new Web.Model.Product()); %>";
</script>
Unfortunately this seems to break. At least the quotes (“) aren’t escaped (\”). How could I “inject” the results of RenderPartial into JS?
Instead of storing it as a variable, you can just put it in a placeholder, like this:
Then when you want to use it, get it via
.innerHTML, like this:This is useful in other scenarios, if you want to clone it, etc…it all depends how you intend to use it, but I’ve found this a much more useful approach in most cases.