primefaces keyup or other ajax event delay

后端 未结 4 1703
一个人的身影
一个人的身影 2020-12-03 04:59

I have something like:


    
         


        
4条回答
  •  醉梦人生
    2020-12-03 05:56

    Why don't you use PrimeFaces' RemoteCommand component?

    It gives you a global Javascript function, that you can call from wherever whenever you want. And it lets you call the managed-bean method and it has the update attribute for partial update.

    
    
    
        
    
    

    Register event handler, I borrowed the following from the same answer you posted:

    var delay = (function() {
        var timer = 0;
        return function(callback, ms) {
            clearTimeout (timer);
            timer = setTimeout(callback, ms);
        };
    })();
    
    
    jQuery("#input").keyup(function() {
        delay(function() { sendAjaxical(); }, 2000); //sendAjaxical is the name of remote-command
    });
    

提交回复
热议问题