title: Partial view remains active after close
body: <p>I have a view in which I have a kendo-grid, in this grid there is a button to open a detail window. When the button is pressed the detail window opens which is a kendo-window which renders a partial view. When I close the kendo-window I destroy it and set it to null. However I have a JavaScript function on both my view and my partial view that catches the input of a scanner. If I scan while the window with the partial view is open the function on the view does nothing, however when I close the partial view the JavaScript function on the partial view still catches my scans and it tries to process the scan for both pages at once. How can I make sure the partial view is really closed so that it doesn't catch my scan input (preferably with JavaScript).</p>
  
  <p>Partial view action method:</p>
  
  <pre><code>public ActionResult GetKendoWindow(int ID, int PID)
  {
    //fill and return partial view locationswindow
    ViewBag.ID = ID;
    ViewBag.PID = PID;
    IEnumerable&lt;BinLocationItemModel&gt; model = dbLogic.getItemLocations(PID, ID);
  
    return PartialView("_PartialViewLocation", model);
  }
  </code></pre>
  
  <p>Kendo-window:</p>
  
  <pre><code>function showDetails(e) {
  e.preventDefault();
  if (wnd) {
    wnd.close();
  }    
  var dataItem = this.dataItem($(e.currentTarget).closest("tr"));
  wndOpen = 1;
  
  $("#detcont").append("&lt;div id='Details'&gt;&lt;/div&gt;");
  
  wnd = $("#Details").kendoWindow({
    width: "60%",
    height: "60%",
    actions: ["Minimize", "Maximize", "Close"],
    title: "Location Data for: " + dataItem.ArticleID,
    content: {
      url: "GetKendoWindow",
      type: "GET",
      data: { ID: dataItem.LineNum, PID: dataItem.PickID }
    },
    close: function (e) {
      wnd.destroy();
      wnd = null;
      setWindowInactive();
    }
  }).data("kendoWindow");
  
  wnd.center().open();
  
  }
  
  function setWindowInactive(e) {    
  wndOpen = 0;
  }
  </code></pre>
  
  <p>Partial View JS:</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
    //Scanner opvangen
    $(document).ready(function () {
        if ($('#ItemLocGrid') != null) {
            var pressed = false;
            var chars = [];
            var grid = $('#ItemLocGrid').data('kendoGrid');
            var dataitem = grid.dataItem(grid.select());
  
            $(window).keypress(function (e) {
                if (e.which &gt;= 48 &amp;&amp; e.which &lt;= 57) {
                    if (chars.length &lt; 3) {
                        // do nothing
                    } else {
  
                        $('.focus :input').focus();
                    }
                    chars.push(String.fromCharCode(e.which));
                }
                if (pressed == false) {
                    setTimeout(function () {
                        if (chars.length &gt;= 5) {
                            var barcode = chars.join("");
                            document.getElementById("txtBarcodes").value = barcode;
                            $('.focus :input').submit();
                        }
                        chars = [];
                        pressed = false;
                        document.getElementById("txtBarcodes").value = "";
                    }, 200);
                }
                pressed = true;
            });
        }
    });
  
    $('#txtBarcodes').submit(function (e) {
        var grid = $("#ItemLocGrid").data("kendoGrid");
        var dataSource = $("#ItemLocGrid").data("kendoGrid").dataSource;
        var allData = grid.dataSource.data();
        var code = this.value;
        var notification = $("#notification").data("kendoNotification");
        console.log("Nothing to see here");
    })
  </code></pre>
  
  <p></p>