Topic: execute javascript function each time a xajax response

Is it possible to set a javascript function to execute each time a xajax response?

I want to disable the autofeed on the news inputs. So I have the following function:

                    function desabilitarAutoFeed()
                    {
                        var tags = document.getElementsByTagName("input");
                        for(var j=0;j<tags.length;j++)
                        {
                            if(tags[j].type=="text")
                            {
                                tags[j].setAttribute("autocomplete","off");
                            }
                        }
                    }
So I have to call each time: $objResposta->script('desabilitarAutoFeed()');
Is it possible  to make it automatic?
Regards,
Guilherme

Re: execute javascript function each time a xajax response

Hi,

Take a look at this code:

<script type="text/javascript">
  <!--
  xajax.callback.global.onResponseDelay = showLoading;
  xajax.callback.global.onComplete = hideLoading;
  
  function showLoading() {xajax.$('loading').style.display='block';}
  function hideLoading() {xajax.$('loading').style.display = 'none';}  
  -->  
</script>

The global onComplete function is probably what you need.

xajax.callback.global.onComplete = hideLoading;

Ed

If you ever stop learning you may as well dig a hole, crawl in and pull the top over yourself.

Re: execute javascript function each time a xajax response

That's exactly what I was looking for.
I just had to insert
xajax.callback.global.onComplete = function() {   myfunction() };
after
$xajax->printJavascript("../../../Sistema/xajax".$versaoxajax."/");

to do what I want.
Now I'm looking is it possible to know if there are some new input? So I don't have to execute a input search all the time. Or maybe it isn't so bad do to it all the time, is it?

Re: execute javascript function each time a xajax response

The solution I got is:
            var qtdinputelement = 0;
            xajax.callback.global.onComplete = function()
            {
                if(qtdinputelement!=document.getElementsByTagName("input").length)
                {
                    qtdinputelement = document.getElementsByTagName("input").length;
                    desabilitarAutoFeed();
                }
            };
I think that's enough.
Thank you Edrobinson!

Re: execute javascript function each time a xajax response

Find atlanta credit repair in Atlanta. Read Ratings and Reviews on Atlanta Credit Repair Services on Angie’s List so you can pick the right Credit Repair Business the first time.