Topic: Several loaders images as callbacks

Hi,

Can you tell me how to make different callbacks from several HTML's divs?

A.E. : I've got two different xajax functions and I want do display different divs when they're processed.

PHP/XAJAX

Code: PHP

function cat () {

$objResponse = new xajaxResponse();

...

return $objResponse;

}

function dog () {

$objResponse = new xajaxResponse();

...

return $objResponse;

}

 

HTML

Code: PHP

<div id='loader_cat' />

<div id='loader_dog' />

 

Basically for one div I'm using xajax.callback.global.onRequest and xajax.callback.global.beforeResponseProcessing, but I don't have an idea how to use it for diffrent divs and functions.

Please help smile

Re: Several loaders images as callbacks

Hi,

You can avoid using the callbacks altogether by assigning the div stles using the response assign() function.

See here:

http://community.xajaxproject.org/topic … -propiety/

Ed

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

Re: Several loaders images as callbacks

I've already try this solution. It works but only for greater then first xajax function call. First call displays old style - it's logical. It'll be better if I could assign different divs for each functions...

Last edited by piotrycjan (2010-02-08 5:59:13 PM)

Re: Several loaders images as callbacks

You can alter the callbacks at every call...

Code: PHP

<script>

  function setupProcessing(divid)

  {

    xajax.callback.global.onRequest = function() {xajax.$(divid).style.display='block';}

    xajax.callback.global.beforeResponseProcessing = function()

       {xajax.$(divid).style.display='none';}

  }

</script>

...

<html>

...

<input ... onclick="setupProcessing('div1');xajax_myFunc1(...);"/>

<input ... onclick="setupProcessing('div2');xajax_myFunc2(...);"/>

...

</html>

 

This is from a sample loading message example but you could alter it to hide all divs that are not to be shown and show the passed div id. Might only need the onrequest function.

Ed

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

Re: Several loaders images as callbacks

Great idea, thanx Ed!

Re: Several loaders images as callbacks

For all who try this or want to display the loading-message not at every xajax-Request:

Code: PHP

  <script>  

    function lsc(bo)

    {

      if (bo == "yes") {      

        xajax.callback.global.onRequest = function() {xajax.$('loading').style.display = 'block';}

        xajax.callback.global.beforeResponseProcessing = function() {xajax.$('loading').style.display='none';}

      } else {

        xajax.callback.global.onRequest = function() {}

        xajax.callback.global.beforeResponseProcessing = function() {}          

      }

    }

  </script>

 

Code: PHP

<a href="#" onClick="lsc('no');xajax_abc();">No Loading Screen</a>

 

Code: PHP

<a href="#" onClick="lsc('yes');xajax_xyz();">Show Loading Screen</a>

 

Or is there another method to do this?

Thank you...
dsta

Re: Several loaders images as callbacks

Hi,

That looks as good as any...

Ed

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