oracle 基于 $(document) jQuery 选择器的自定义事件动态操作

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/28538570/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:44:13  来源:igfitidea点击:

Custom Event Dynamic Action based on $(document) jQuery selector

javascriptjqueryoracledomoracle-apex

提问by Drumbeg

I've been using dynamic actions based on custom events in one of my Oracle Apex pages. I am binding my event to the document and then using a 'DOM Object' selection type (of document) in order to specify the context for the event.

我一直在我的 Oracle Apex 页面之一中使用基于自定义事件的动态操作。我将我的事件绑定到文档,然后使用“DOM 对象”选择类型(文档的)来指定事件的上下文。

enter image description hereThis works in Apex 4.2, however I have just come across this in relation to Apex 5:

在此处输入图片说明这适用于 Apex 4.2,但是我刚刚遇到了与 Apex 5 相关的问题:

https://docs.oracle.com/cd/E59726_01/doc.50/e39143/toc.htm#BAJDAGJG

https://docs.oracle.com/cd/E59726_01/doc.50/e39143/toc.htm#BAJDAGJG

5.10 Deprecation of Dynamic Actions Based on DOM Objects

Dynamic actions based on DOM Objects have been deprecated. Change your dynamic actions to use a jQuery Selector or JavaScript Expression instead of DOM Object.

5.10 弃用基于 DOM 对象的动态动作

基于 DOM 对象的动态操作已被弃用。更改您的动态操作以使用 jQuery 选择器或 JavaScript 表达式而不是 DOM 对象。

My question is, how can I use a jQuery selector in order to detect events bound to the document? When I try using a jQuery selector of document, the dynamic action does not fire. I strongly suspect that this is because APEX wraps the selector in quotes when the dynamic action is parsed, rendering it useless for selectors on the document or window objects.

我的问题是,如何使用 jQuery 选择器来检测绑定到文档的事件?当我尝试使用 jQuery 选择器时document,不会触发动态操作。我强烈怀疑这是因为 APEX 在解析动态操作时将选择器用引号括起来,使其对文档或窗口对象上的选择器无用。

I am already aware that in the standard jQuery world I would just use $(document).

我已经知道在标准的 jQuery 世界中,我只会使用$(document).

enter image description here

在此处输入图片说明

I already know that I can bind events to different DOM elements. I'm not interested in that. I am interested specifically in binding to document.

我已经知道我可以将事件绑定到不同的 DOM 元素。我对此不感兴趣。我对绑定到文档特别感兴趣。

采纳答案by Bacs

jQuery selectors return element nodes. Your event is bound to the document node, so there's no way to get at it with a jQuery selector. $(document)is not strictly speaking a selector. I believe $(":root").parent()returns the documentobject but that doesn't help you, since Oracle only lets you use selectors, not methods.

jQuery 选择器返回元素节点。您的事件绑定到文档节点,因此无法使用 jQuery 选择器来处理它。$(document)严格来说不是选择器。我相信$(":root").parent()返回document对象,但这对您没有帮助,因为 Oracle 只允许您使用选择器,而不是方法。

Oracle got back to me earlier with my Apex 5 workspace, so I've been having a play. The solution is in the documentation you quoted. You can't use a jQuery selector in your dynamic action's Selection Type, but you can simply use a Javascript Expression, with the value: document

Oracle 早些时候回复了我的 Apex 5 工作区,所以我一直在玩。解决方案在您引用的文档中。您不能在动态操作的选择类型中使用 jQuery 选择器,但您可以简单地使用具有以下值的 Javascript 表达式:document

I tested this by creating a button pointing to the URL:

我通过创建一个指向 URL 的按钮对此进行了测试:

javascript:apex.event.trigger(document,'testEvent');

I created a dynamic action responding to the Custom Event testEvent, Selection Type Javascript Expression, expression value document. It works fine, and the button now triggers an alert via a custom event handled at the document.

我创建了一个响应自定义事件testEvent、选择类型Javascript Expression、表达式值的动态操作document。它工作正常,按钮现在通过在文档中处理的自定义事件触发警报。

回答by Etay Gudai 972-522-3322-47

Short Example: How a dynamic action custom event placed ( oracle apex 18.1) to refresh interactive reportsection :

简短示例:如何放置动态操作自定义事件(oracle apex 18.1)以刷新交互式报告部分:

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明

enter image description here

在此处输入图片说明