【发布时间】:2015-12-12 20:28:21
【问题描述】:
我在 WinJS 中有一个单页应用程序。在 default.html(这是默认页面)中,我有 div,我在其中呈现来自同一目录的其他页面。
<div id="pagebody"><!--Here is page rendered--> </div>
现在,在那个页面(呈现到那个 div 中)我有 ListView。在 ListView 模板中,对于每个 ListViewItem 我都有输入控件 - 复选框
<input name="ListViewCheckBox" type="checkbox"/> <!--in js I fetch all inputs with name ListViewCheckBox-->
现在,我必须在所有输入都被渲染后捕获事件,以便能够根据“应用程序状态”对它们进行某事。在 default.js 文件中,我调用函数 WinJS.UI.Pages.render() 和 WinJS.UI.processAll()
WinJS.UI.processAll().done(function () {
//if I try to fetch all inputs here, I get list with 0 elements (as expected)
});
WinJS.UI.Pages.render("OtherPage.html", PageBody).done(function () {
//if I try to fetch all inputs here, I get list with precisely one item
//it catches input declared in template
//the problem is that I need input from each listviewitem
//(if there are for example 20 listviewitems, and I need to fetch all 20 inputs)
});
我使用以下代码行获取输入:
var Inputs = document.getElementsByName("ListViewCheckBox");
如何在呈现每个输入时捕获该事件,因此我获取所有输入。
【问题讨论】:
-
这有可能吗?
标签: javascript listview input winjs uwp