Hi!
I would like to say that i have already read similiar
topics in this forum and none of them solved my problem. When im trying
to access dynamically created window data("kendoWindow") the result is
undefined :/
So i've got a "Contractors" View which got almost nothing inside it, besides kendo Grid and few buttons + this placeholder:
<
div
id
=
"editContractorNaturalPersonWindow"
></
div
>
When a user clicks the button, window is opened:
$(
".contractorNaturalPerson"
).click(
function
() {
var
dataUrl = $(
this
).data(
"url"
);
$(
"#editContractorNaturalPersonWindow"
).kendoWindow({
content: {
title:
"title123"
,
url: dataUrl
},
open:
function
() {
kendoWindow_center(
"#editContractorNaturalPersonWindow"
);
},
refresh:
function
() {
kendoWindow_center(
"#editContractorNaturalPersonWindow"
);
}
});
var
dialog = $(
"#editContractorNaturalPersonWindow"
).data(
"kendoWindow"
);
dialog.open();
});
Till now everything works, window is being opened, centered, etc. Inside dynamically loaded "EditContractorNaturalPerson" Partial View i've got a simple form with few textboxes and this script:
$(
'.editContractorNaturalPersonForm'
).submit(
function
() {
if
($(
this
).valid()) {
$.ajax({
url:
this
.action,
type:
this
.method,
data: $(
this
).serialize(),
success:
function
(data) {
if
(data.result ==
"Success"
) {
debugger;
var
dialog = $(
"#editContractorNaturalPersonWindow"
).data(
"kendoWindow"
);
dialog.close();
$(
'#contractorsGrid'
).data(
'kendoGrid'
).dataSource.read();
return
false
;
}
else
if
(data.result ==
"Error"
) {
debugger;
for
(prop
in
data.modelErrors) {
if
(data.modelErrors[prop].length > 0) {
$(
"#"
+ prop).next().text(data.modelErrors[prop]);
}
}
}
},
error:
function
(xhr, ajaxOptions, thrownError) {
alert(
"EditContractorNaturalPerson-AjaxError"
);
}
});
}
return
false
;
});
This line:
var
dialog = $(
"#editContractorNaturalPersonWindow"
).data(
"kendoWindow"
);
Gives me undefined, EVEN THAT jQuery found this object:
$(
"#editContractorNaturalPersonWindow"
)
I already tried to remove window by destroying this jquery object (k-window) but it breaks its functionality. What can i do ? Please help :)