Problems using partial views containing EJ controls
i'm migrating an MVC 5 app to asp.net core. in mvc5, I was told that I need to call ej.widget.init in my AJAX handler in order to activate the controls. For example:
function onChange(args) {
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status == 200) {
$("#homeContent").html(this.responseText);
ej.widget.init($("#homeContent")); // Initiate control rendering
}
};
xhttp.open("POST", "/Home/Date", true);
xhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
xhttp.send("d=" + args.value);
I'm assuming that this has changed somewhat for Core - as all I get on the page after the AJAX is an empty rectangle where the control should have been. What's the proper way to do this in asp.net core?
Upon running the project, I get the same kind of result that I experienced in my main project. I did notice a problem, in the form of a JavaScript exception - a TypeError saying "ej.widget.init is not a function".
I've attached the project.
Attachment: WebApplication3_7c0cb762.zip
Attachment: WebApplication3b_69b685c4.zip
<ej-date-picker id="DatePick1" value="DateTime.Today"></ej-date-picker>
<button onclick="loadGrid()">Reload content</button><br /><br />
<div id="contentzone">
@Html.Partial("_homeContent.cshtml", Model)
</div>
In this case, neither the main page control (i.e., DatePick1) nor the one on the partial render correctly. They're both an empty input with no content or decoration.
This is very similar to my "real" app... several pages have a DatePicker along with a partial, which reloads in the OnChange of the DatePicker.
I'm not interested in pursuing this any further at this point... the partial views & AJAX weren't that essential to the application - 99% of the page would have been reloaded in most of the cases. I'm going to just put the stuff that had been on a partial on the main page(s).
I do sincerely thank you for the help.
- 10 Replies
- 3 Participants
-
RB R Brian Lindahl
- Apr 20, 2017 04:21 PM UTC
- May 3, 2017 12:15 PM UTC