简体   繁体   English

在LiveCycle Designer中单击按钮时隐藏母版页元素

[英]Hide Master Page element on button click in LiveCycle Designer

This seems straightforward but I have yet to find a clear answer to this. 这似乎很简单,但是我还没有找到明确的答案。

I have a dropdown box with global binding in a Master Page. 我在母版页中有一个带有全局绑定的下拉框。 I would like a separate button, located in the design content area ( not the Master Page), when clicked, to tell any instances of the dropdown box in the Master Page(s) to hide, or be visible, etc. 我想在设计内容区域( 不是母版页)中单击一个单独的按钮,以告诉母版页中下拉框的任何实例隐藏或可见等。

In the SOM editor, the dropdown box tells me its hierarchy is: 在SOM编辑器中,下拉框告诉我其层次结构为:

form1.MasterPages.Page1.Header.projectSize

In the button's JavaScript on Click I've tried: 在“点击”按钮上的JavaScript中,我尝试过:

xfa.resolveNodes("form1.MasterPages.Page1[*].Header.projectSize").presence="hidden";

and

var nodes = form1.MasterPages.resolveNodes("Page1[*].Header");
var len = nodes.length;
for(var i = 0; i < len; i++) {
  nodes.item(i).projectSize.presence="hidden";
}

and a similar script with an xfa.resolveNodes(" before form1.Master... , all of which do not work. 以及在form1.Master...之前带有xfa.resolveNodes("的类似脚本,所有这些脚本均不起作用。

Is it possible to target Master Page elements, and if so, what would be the correct syntax? 是否可以定位母版页元素,如果是,正确的语法是什么?

Thank you in advance. 先感谢您。

Edit* 编辑*

So upon closer inspection, the var nodes method actually works. 因此,在仔细检查后,var节点方法实际上是可行的。 But it only works when the button is clicked a second time. 但是它仅在第二次单击按钮时有效。 The other scripts that are run when the button is clicked work fine, but the Master Page dropdown only "hides" when the button is clicked again... Apparently this is the issue now. 单击该按钮时运行的其他脚本运行正常,但是再次单击该按钮时,“母版页”下拉列表仅“隐藏” ...显然,这是现在的问题。

I've figured out my problem. 我已经解决了我的问题。 Not sure if this can help anyone else, but here is my solution, though I don't completely understand why it works. 不知道这是否可以帮助其他任何人,但这是我的解决方案,尽管我不完全了解它为什么起作用。

To target the dropdown element on every potential iteration of the Master Page, and then to hide each iteration, this JavaScript works in a button located in the document body (I believe it is the same as I initially stated): 要将dropdown元素定位到母版页的每个潜在迭代上,然后隐藏每个迭代,此JavaScript在文档正文中的按钮中起作用(我相信它与我最初所说的相同):

var nodes = form1.MasterPages.resolveNodes("Page1[*].Header");
var len = nodes.length;
for (var i = 0; i < len; i++){
  nodes.item(i).projectSize.presence="hidden";
}

Upon tearing apart the other scripts that ran along side of this one, I found that another table, and the script I was using to hide it with, was the reason the Master Page dropdown element needed two clicks to run properly. 拆解该脚本旁边运行的其他脚本后,我发现另一个表以及用来隐藏该脚本的脚本是“母版页”下拉元素需要两次单击才能正常运行的原因。

The culprit table is called notesTable and is located in a subform called GrandTotals . 罪魁祸首表称为notesTable ,位于名为GrandTotals的子窗体中。 The following script worked fine with the other scripts, but failed once the Master Page referencing script came into play: GrandTotals.notesTable.presence="hidden"; 以下脚本可以与其他脚本正常工作,但是一旦母版页引用脚本开始起作用,该脚本将失败GrandTotals.notesTable.presence="hidden";

The workaround I found to make everything work together on the first click was to reference each cell item within notesTable and hide them independently: 我发现要使所有功能在第一次单击时都可以正常工作的解决方法是引用notesTable每个单元格项并独立隐藏它们:

form1.GrandTotals.notesTable.HeaderRow.notesHeader.presence="hidden";
form1.GrandTotals.notesTable.Row1.notes.presence="hidden";

I only had 2 cells to target so it wasn't a huge deal, but I can imagine this solution turning messy with many rows and cells, etc. Either way, a redundant, longer, hack fix is still a fix. 我只有2个单元作为目标,所以这并不是什么大问题,但是我可以想象到该解决方案会变得杂乱无章,并包含许多行和单元,等等。无论哪种方式,冗余的,更长的,hack的修复仍然是一个修复。

I am still unsure of why this problem arose, and why this solves it. 我仍然不确定为什么会出现这个问题,以及为什么会解决这个问题。 I had some other problems with other referencing JavaScripts that weren't "specific" enough and had to be changed to reference more redundantly specific bits of the hierarchy to work correctly. 我在使用其他引用JavaScript时遇到了其他一些问题,这些JavaScript不够“特定”,因此必须更改为引用层次结构中更多冗余的特定位才能正常工作。 These problems weren't happening a week ago, and now they have been a major road block. 这些问题一周前没有发生,现在已经成为主要障碍。 I'm thinking it might have something to do with some sort of PDF / Reader background update, but I can't be sure. 我认为这可能与某种PDF / Reader背景更新有关,但我不确定。

ANYWAY, here is a random fix to a random issue, but it might clear up some troubleshooting for someone else with a similar confusion. 无论如何,这是对一个随机问题的随机修复,但它可能会为具有类似困惑的其他人清除一些疑难解答。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM