This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.



Nov 21, 2011, 9:05 AM
56 Posts

OnStart/ OnComplete Event of Type Ahead

  • Category: Server Side JavaScript
  • Platform: Not Applicable
  • Release: 8.5.2
  • Role: Developer
  • Tags: TypeAhead,Event,Request,partial
  • Replies: 2
Hello,
 
I have a little problem.
I have a textField with TypeAhead for selecting users from the NAB. Next to this field I want to show a little pic which tells me that something is working, so that the user has some feedback and don't think it isn't working if the lookup takes a little longer.
I want to sho this pic only as long as the lookup takes, that means if he begins to search show it, if I have my result list, hide it.
 
I have tried the onStart and onComplete events, but the Designer told me it is deprecated, and it didn't work. Do you have an idea how to catch the request of the type ahead?
I have looked into some hijacking methods, http://xpagesblog.com/XPagesHome.nsf/Entry.xsp?documentId=EAFB65B6ACCB8A63852578CB0066A829 (very interesting method by the way), but it requires me to install something on the Notes Server. Because I am developing a very generic control, which I will publish, this isn't the best method.
 
Do you have another idea?
 
Thank you very much.
Nov 23, 2011, 2:01 PM
56 Posts
Re: OnStart/ OnComplete Event of Type Ahead
Hey,
 
I found out (with the help of Sven) the reason why there is no onError/complete/start event. It's because there is no partial refresh at all which could have such events. In Dojo they use a XHRGet to fetch the data. Only solution could be to hijack the function in which the XHRGet is done. Any ideas? =)
 
Thanks advance
Dec 5, 2011, 7:44 AM
272 Posts
Re: OnStart/ OnComplete Event of Type Ahead
Hi,
 
here is a hack which has to be added to a CSJS scriptblock.
Just change the code where you find the alerts.
 
var typeAheadLoad;

dojo.addOnLoad( function(){
    /*** hijacking xhr request ***/
    if( !dojo._xhr )
        dojo._xhr = dojo.xhr;

    dojo.xhr = function( args1, args2 ){
        /*** hook in load function ***/
        typeAheadLoad = args2["load"];

        /*** overwrite error handler ***/
        args2["error"] = function(){ alert('Error raised!') };

        args2["load"] = function(arguments){
            /*** do what you want here ***/
            alert("Before!");
            typeAheadLoad(arguments);
            /*** and here! ***/
            alert("On Complete!")
        };
        dojo._xhr( arguments[0], arguments[1] );
    }
});
 
Sven
 

This forum is closed to new posts and responses. New discussions are now taking place in the IBM Developer Answers forum.