在 XPage 中获取 typeAhead 的 dijit [英] Getting the dijit for a typeAhead in XPages
问题描述
我希望能够向表单上的所有 TypeAhead 字段添加 onBlur/onkeypress/onChange 事件,而不是让开发人员在 Designer 客户端中选择每一个.我唯一无法处理的是 onChange 事件.
I want to be able to add an onBlur/onkeypress/onChange events to all TypeAhead fields on the form rather than have a developer select every one in the Designer client. The only thing I cannot get a handle on is the onChange event.
当用户在 TypeAhead 中选择某些内容时,将代码直接添加到 Domino Designer 中的事件时会触发 onChange 事件 - 因此我应该能够用代码复制该功能.
When the user selects something in the TypeAhead the onChange event is triggered when adding the code directly to the event in the Domino Designer - so I should be able to replicate that capability with code.
如果我的 typeAhead 字段被称为 inputText2,我认为我可以执行以下操作
If my typeAhead field is called inputText2 I thought I would be able to do the following
var widget = dojo.byId("#{id:inputText2}")
dojo.connect(widget, 'onChange', function (){
alert('1')
});
但是这似乎不起作用...
However this doesn't appear to work...
我试过小写 onchange
I tried lowercase onchange
var widget = dojo.byId("#{id:inputText2}")
dojo.connect(widget, 'onchange', function (){
alert('1')
});
也没有运气
我试过了
var widget = dijit.byId("#{id:inputText2}");
但未能完全选择元素
那么在 typeAhead 中选择一个选项时,我需要做什么来触发 onchange 事件?
So what do I need to do to trigger the onchange event when selecting an option in the typeAhead?
推荐答案
我找到了一个解决方案.....不理想,但目前有效 - 虽然不是通用的,但一个开始
I found a solution.....not ideal but it worked for the moment - not generic though, but a start
复制 XPage 的方式....将其添加到页面
Copying the way XPages does it....add this to the page
function view__id1__id2__id31__id50_clientSide_onchange(thisEvent) {
alert('me')
}
然后
dojo.addOnLoad(function(){
XSP.addOnLoad(function() {
XSP.attachEvent("X1","view:_id1:_id2:_id31:inputText2", "onchange", view__id1__id2__id31__id50_clientSide_onchange, false, 2);
});
});
});
X1 必须是唯一的,但其他一切都可以计算
X1 must be unique but everything else can be calculated
感谢 Serdar Basegmez
Thanks to Serdar Basegmez
这篇关于在 XPage 中获取 typeAhead 的 dijit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!