Wednesday, December 19, 2018

How do I hand a partial into a partial from a Razor view wrapping the second partial?

You could make a div in the partial and inject stuff into it like so:

<script type="text/javascript">
   $(document).ready(function () {
      $.ajax({
         type: "GET",
         url: "/Yin/Yang",
         dataType: 'html',
         success: function (result) {
            $("#nestedGunk").html(result);
         },
         error: function (error) {
            console.log("error in reaching out to /Yin/Yang");
            console.log(error);
         }
      });
   });
</script>

 
 

If you want to do a post instead of a get and hand over the model, you can get at the model like this:

var json = @Html.Raw(Json.Serialize(@Model));

No comments:

Post a Comment