reidLinden
reidLinden

Reputation: 4170

Should MVC4 PartialView ajax loading fire a "pageinit" event?

In my asp.net mvc4 + jquerymobile app, I have a 'page' which looks something like this:

+---------------------------------------+
|A                                      |
|   +----------------+----------------+ |
|   |B               |C               | |
|   |                | +------------+ | |
|   |                | |D           | | |
|   |                | +------------+ | |
|   +----------------+----------------+ |
+---------------------------------------+

All four views I have some version of this script, to tell me which events are firing, when:

$(document).ready(function () {
    console && console.log("portalUser (pvUserEdit) document ready!!");
});
$(document).on('pageinit', function () {
    console && console.log("portalUser (pvUserEdit) pageInit!!");
});

When page A is first loaded, page B is loaded alongside, and both the pageinit event and the DOM ready event fire for both of them. When an item from the list in B is selected, it generates an ajax load to fill panel C (which causes panel D to also load). This time, only the DOM ready event fires for both C & D panels, never firing the pageinit event.

So, thats all the background info. The QUESTION is: is this the expected behavior, considering the MVC4+JQM aspect of the project? Should I expect pageinit to fire on partialView loads? Or do I need to handle the partial views differently than full pages?

Upvotes: 1

Views: 379

Answers (1)

Sergio
Sergio

Reputation: 6948

Javascript has no idea what kind of backend is running, so it's definitely not mvc issue. It may vary in different browsers but it's definitely differs because of ajax page loading

Upvotes: 0

Related Questions