Cecil Westerhof ha scritto:
2009/10/2 Giovanni Battista Lenoci <gian...@gmail.com>:
first the easy thing:

Is there a way to let the fadeOut be finished before continuing?

Yes, fadeOut accept a callback function that is called after the effect end,
take a look here:

http://docs.jquery.com/Effects/fadeOut#speedcallback

That I allready found. I tried the folowing:
        $(placeInDOM).replaceWith(header + fields + footer);
        $('.submit_' + formID).click(function() {
          var fadeOutReady = false;
          var fadeSpeed    = 1500;
          var form = $('#' + formID);

          form.fadeOut(fadeSpeed, function() {
            fadeOutReady = true;
          });
          while( !fadeOutReady ) {
            // wait untill fadeOut is ready
          }
          jQuery.post(cgiURL,
            form.serialize(),
            function(xml) {
              alert($(xml).find('status').text() + '\n' +
$(xml).find('duration').text());
              form.fadeIn(fadeSpeed);
            },
            "xml"
          );
          return false;
        });

But when I use this code, my processor is very busy and the fadeOut
does not happen.
Yes, because fadeOut is asinc, then after calling it you stop the javascript execution with the while, and the fadeOutReady will be always false, you have to do this (not tested, but should work):

form.fadeOut(fadeSpeed, function() {
                         jQuery.post(cgiURL,
                                     form.serialize(),
                                     function(xml) {
                                       alert($(xml).find('status').text() + 
'\n' +
                                        $(xml).find('duration').text());
                                       form.fadeIn(fadeSpeed);
                                     },
                                     "xml"
                                    );
                       });

I know use:
        $(placeInDOM).replaceWith(header + fields + footer);
        $thisForm = $('#' + formID);
        $(':submit', $thisForm).click(function() {

I do not need a class anymore. I want to change the click event for
all the submit buttons of the form and no other submit buttons. The
above code does this.

I prefer the way I do it know. In this way the HTML-page or the
function can change the way the id's are made, without breaking
anything. In the above way the HTML and function has to be
synchronized. I prefer to minimize the possibilities to break things.
You're right, the :submit selector is better... i did a fast copy and paste :-)

p.s.

"I now use", not "I know use"... and please if you find any error on my posts please correct me, I have to learn a lot about english (and jquery too) :-)

Bye

--
gianiaz.net - web solutions
via piedo, 58 - 23020 tresivio (so) - italy
+39 347 7196482

Reply via email to