Hi,
I'm so close I can taste it.
I have a razor page (we'll call Main) and it pops a windows from a button called AddItem.
That window, (AddItem) will pop another window from a button on it called AddFeature.
I can get the windows popping up just fine. However when I try to submit the form on the AddFeature window. I can't figure out how to close it afterward.
Bottom line is that when I click to save the new feature, the window does not close. The post happens and things get saved to the db, but it appears that my code to close the window does not get called. The code below is heavily redacted so there may be some typos but it should get the idea across.
The question remains, what's the right way to do this?
Any help would be great.
Code below:
<
body
>
<
div
class
=
"container-fluid body-content"
>
@(Html.Kendo().Window()
.Name("AddItem")
// .Width(100)
// .Height(100)
.Resizable()
.Modal(true)
.Scrollable(true)
.Title("Add New User")
.Visible(false)
.Actions(actions => actions.Refresh().Minimize().Maximize().Close())
.Content("loading ...")
.LoadContentFrom(Url.Content("~/Admin/AddItem"))
.Animation(true)
.Draggable(true)
)
<
form
method
=
"post"
id
=
"frmMain"
asp-page-handler
=
"Main"
asp-page
=
"Main"
>
.
.
.
javascript function to pop window in response to button click
function OnNewItem()
{
var win = $("#AddNewItem").data("kendoWindow");
win.center().open();
}
// now on the item page we have a button that pops the following window
<
body
>
<
div
class
=
"container-fluid body-content"
>
@(Html.Kendo().Window()
.Name("AddNewFeature")
.Resizable()
.Modal(true)
.Scrollable(true)
.Visible(false)
.Actions(actions => actions.Refresh().Minimize().Maximize().Close())
.Content("loading ...")
.LoadContentFrom(Url.Content("~/Admin/AddFeature"))
.Animation(true)
.Draggable(true)
)
<
form
method
=
"post"
id
=
"frmItem"
asp-page-handler
=
"Item"
asp-page
=
"Item"
>
.
.
.
// now on the feature page:
<body>
<form asp-route-returnUrl="@Model.ReturnUrl" asp-page-handler="NewFeature" asp-page="NewFeature" method="post" id="theNewFeatureForm">
…
<
input
type
=
"submit"
id
=
"update-button"
onclick
=
"DoSave();"
class
=
"btn btn-primary"
value
=
"Save"
/>
…
function DoSave()
{
$('#theNewFeatureForm').submit(function (e)
{
e.preventDefault();
$.ajax({
url: '/Admin/AddNewFeature',
type: 'POST',
dataType: 'json',
data: $(this).serialize(),
success: function (data)
{
var win = $("#AddNewFeature").data("kendoWindow");
win.close();
}
});
});