Getting the dijit for a typeAhead in XPages

故事扮演 提交于 2019-12-11 07:37:15

问题


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.

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.

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...

I tried lowercase onchange

        var widget = dojo.byId("#{id:inputText2}")
        dojo.connect(widget, 'onchange', function (){
            alert('1')
        });

no luck there either

I tried

    var widget = dijit.byId("#{id:inputText2}");

but that failed to event select the element entirely

So what do I need to do to trigger the onchange event when selecting an option in the typeAhead?


回答1:


I found a solution.....not ideal but it worked for the moment - not generic though, but a start

Copying the way XPages does it....add this to the page

             function view__id1__id2__id31__id50_clientSide_onchange(thisEvent) {
                alert('me')
            }

and then

        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 must be unique but everything else can be calculated

Thanks to Serdar Basegmez



来源:https://stackoverflow.com/questions/9892326/getting-the-dijit-for-a-typeahead-in-xpages

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!