使用 javascript/jQuery 在 oracle apex 中以编程方式禁用按钮
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/3300463/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Disable button programmatically in oracle apex using javascript/jQuery
提问by maximus
I'm trying to disable a button inside of a form region in Oracle Application Express (Apex v3) in an ajax-ified manner. I'm using jQuery to accomplish the ajax part.
我正在尝试以 ajax 化的方式禁用 Oracle Application Express (Apex v3) 中表单区域内的按钮。我正在使用 jQuery 来完成 ajax 部分。
$('#P16_MYBUTTON').hide();
Doing a view source on the rendered page I noticed that the button doesn't have an ID even though in Apex I've given it a name. I scanned through the rest of the code and noticed that other elements do have an ID. This behavior is somewhat confusing to me.
在呈现的页面上查看源代码时,我注意到该按钮没有 ID,即使在 Apex 中我已经给了它一个名称。我浏览了其余的代码并注意到其他元素确实有一个 ID。这种行为让我有些困惑。
Any ideas?
有任何想法吗?
回答by Tony Andrews
Apex 4.0 does assign an ID to each button automatically. In Apex 3.x you can assign one yourself via the button's Attributes property:
Apex 4.0 会自动为每个按钮分配一个 ID。在 Apex 3.x 中,您可以通过按钮的 Attributes 属性自己分配一个:
id="P16_MYBUTTON"
If the button is an HTML button then that is sufficient to make it work; if the button is based on a template then you need to ensure that the template definition contains the #BUTTON_ATTRIBUTES# substitution string in an appropriate position - for example:
如果按钮是 HTML 按钮,则足以使其工作;如果按钮基于模板,那么您需要确保模板定义在适当的位置包含 #BUTTON_ATTRIBUTES# 替换字符串 - 例如:
<a class="myButton" href="#LINK#" #BUTTON_ATTRIBUTES#>#LABEL#</a>
回答by Jose Diaz
I don't know how Apex does its rendering thing, however, you could use another JQuery selector to locate the button, for instance, if you know the ID or html tag name of the direct parent of this button you could use something like:
我不知道 Apex 是如何进行渲染的,但是,您可以使用另一个 JQuery 选择器来定位按钮,例如,如果您知道此按钮的直接父级的 ID 或 html 标记名称,则可以使用以下内容:
$('form > button:first').hide()
For future reference, download this refcard:
为了将来参考,请下载此参考卡: