title: MVC4, Render Partial View in Dialog Box with jQuery, How to refresh
body: <p>I have a partial view that is popping up in a dialog with the code below. However, after the user saves the partial view the data does not refresh in that partial view when I click the ActionLink again until I stop debugging and restart the app. However, the new record is in my databsae. The other issue is when I restart the app I cannot update the record because of the error below. What am I missing? Thanks.</p>
  
  <pre><code>    An object with the same key already exists in the ObjectStateManager. The ObjectStateManager cannot track multiple objects with the same key.
  </code></pre>
  
  <p>The div tag in my View</p>
  
  <pre><code>    &lt;div id="assign-dialog"&gt;&lt;/div&gt;
  </code></pre>
  
  <p>The ActionLink in the same view</p>
  
  <pre><code>    @Html.ActionLink("Assign", "Edit", "Assignment", new { id = Model.InfoId}, new { @class = "assign-modal" })
  </code></pre>
  
  <p>The jQuery</p>
  
  <pre><code>    $(function () {
  
  $(function () {
      $('#assign-dialog').dialog({
          autoOpen: false,
          width: 400,
          height: 500,
          resizable: true,
          modal: true
      });
  
      $('.assign-modal').click(function () {
          $('#assign-dialog').load(this.href, function () {
              $(this).dialog('open');
          });
          return false;
      });
  </code></pre>
  
  <p>});</p>
  
  <p>The HTTP GET action</p>
  
  <pre><code>    [HttpGet]
      [Authorize(Roles="Admin")]
      public ActionResult ViewAssignment(int id = 0)
      {
              RequestAssignment query = _assignmentRepository.GetCurrentAssignment(id);
  
              return PartialView("_ViewAssignment", query)
      }
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>I originally followed the steps in <a href="https://stackoverflow.com/questions/16577011/javascript-jquery-modal-popup-dialog-mvc-4-render-partial-view">javascript/jquery modal popup dialog MVC 4 / render partial view</a> under the dynamic section of Jasen's answer, but did not know what to put in the "Client Partial, empty for now "</p>
  
  <p>...okay so going off some other posts I have read this is what I was able to come up with, but nothing happens when I click my link.</p>
  
  <p>View html</p>
  
  <pre><code>    &lt;a href="#" class="dialog-trigger" data-infoId="@Model.InfoId"&gt;Assign&lt;/a&gt;
      &lt;div id="assign-modal"&gt;
  
      &lt;/div&gt;
  </code></pre>
  
  <p>jQuery</p>
  
  <pre><code>    //Dialog Box for Assignments
   $(".dialog-trigger").on("click", function(event) {
      event.preventDefault();
      var infoId= $(this).data("infoId");
      $.ajax({
          url: "RequestAssignment/Edit/" + infoId,
          type: "GET"
      })
      .done(function(result) {
          $("#assign-modal").html(result).dialog("open");
      });
  });
  </code></pre>