如若MVC4 PartialView AJAX加载火" pageinit"事件? [英] Should MVC4 PartialView ajax loading fire a "pageinit" event?

查看:135
本文介绍了如若MVC4 PartialView AJAX加载火" pageinit"事件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的asp.net mvc4 + jquerymobile应用程序,我有一个页面,这看起来是这样的:

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

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


  • A为pretty简单,只是一个容器页,但它确实没有什么比建立B和其他; C'子页(局部视图)

  • B是UserList的面板(DIV),它有必然的事件,这将导致和C组(局部视图)的AJAX重装

  • C是USEREDIT面板(DIV),含有其它信息的辅助面板。

  • D是UserPermissions面板(DIV),含复选框通过AJAX调用simplemembership角色系统进行交互。

  • 所有的四点看法我有此脚本的一些版本,告诉我哪些事件被触发时:

    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!!");
    });
    

    当第一次加载网页A,网页B时一起加载,无论是pageinit事件和DOM ready事件火了他们两个。如果选择从B中的列表中的项目,它会生成一个ajax负载,以填补C组(这将导致图D也加载)。这一次,只有准备好DOM事件触发为C&放大器; ð板,从来没有烧制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.

    所以,这就是所有的背景资料。现在的问题是:这是预期的行为,考虑到项目的MVC4 + JQM方面?我应该期待pageinit火上partialView负荷?或者,我需要不同的处理部分的观点并不完全页?

    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?

    推荐答案

    JavaScript有不知道正在运行什么样的后台,所以它绝对不是MVC的问题。它可以在不同的浏览器有所不同,但它肯定不同,因为阿贾克斯页​​面加载

    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

    这篇关于如若MVC4 PartialView AJAX加载火" pageinit"事件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆