Knockout Js, jQuery UI Dialog and partial view

I have a requirement that I need to load into the Partial View (razor) in the JQuery Modal dialog box, the problem is that I cannot integrate with Knockout. The implementation will be like this, since the user enters the site, I need to show him the Modal dialog (pop-up - partial view) with the Knockout binding. Any help is appreciated.

+5
source share
1 answer

Since you are going to show the dialog right away, one approach you can use is to simply render the Partial View directly on the main page as a template.

You would define your partial view as follows:

<script id="myPopupTemplate" type="text/html">
   <span data-bind="text: Name"></span>
   <span data-bind="text: Age"></span>
   <button data-bind="click: doSomething">Do Stuff</button>
</script>

:

@Html.RenderPartial("MyPartialView")

, , , jQuery.

<div data-bind="template: {name: 'myPopupTemplate', data: myData}">
</div>
+1

All Articles