Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4609866
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:02:59+00:00 2026-05-22T01:02:59+00:00

I have a form which has a save button. When the save button is

  • 0

I have a form which has a save button. When the save button is clicked it runs ajax to save the form contents. That works. What I am having troubles with is the save button fadein fadeout. The text of the save button is “Save as Draft”. When clicked I would like it to fade out, change the text to “Draft saved at [time]” and then fade in to show that it was saved, and the time it was saved. After a few seconds I would like that button message to fade out and be replaced by the original “Save as Draft” button.

I’m thinking I have to nest the fades into functions, but my jquery fading talents are minimal and fading rapidly 🙂

Below is the success part of the ajax ….

success: function(data) {
    var date = new Date(),
    hours = date.getHours(),
    minutes = date.getMinutes();

    if (hours > 12) hours = hours - 12;
    if (minutes < 10) minutes = '0' + minutes;

    var save_draft = '<div id="save-button" class="button-clone">Save as Draft</div>';
    var draft_saved = '<div id="save-button" class="button-clone">Draft Saved at ' + hours + ':' + minutes + '</div>';

    $('#save-button').fadeOut(1000);
    $('#save-button').replaceWith(draft_saved);
    $('#save-button').fadeIn(1000);
    $('#save-button').fadeOut(1000);
    $('#save-button').replaceWith(save_draft);
    $('#save-button').fadeIn(1000);
}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T01:02:59+00:00Added an answer on May 22, 2026 at 1:02 am

    Since each animation is async, you need to call any other method inside the callback function.

    EDIT

    Sorry, it wasn’t working. Adjusted with fadeIn too:

    $('#save-button').fadeOut("slow", function() {
        $('#save-button').replaceWith(draft_saved);
        $('#save-button').hide().fadeIn(1000, function() {
            $('#save-button').fadeOut(1000, function() {
                $('#save-button').replaceWith(save_draft);
                $('#save-button').hide().fadeIn(1000);
            });
        });
    });
    

    Let me explain why this hide() is being needed:

    When you fadeOut some element, jQuery puts display: none directly to that HTML. But you is replacing with another HTML (by replaceWith() method). But fadeIn() only fades elements that was hidden. So, we need to hide the new HTML and then the fadeIn() happens.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an Ext.FormPanel which has a Save button which is supposed to do
I have a form which has a lot of SELECTs. For various reasons, I'd
I have a form which has only tab control in it. I want to
I have a form which has a Combo Box Control. I have selected the
I have WPF Form which has many buttons with the same code. Appearance of
I have a maximized form which has Combo-Box control (docked in top-right) with 500px
I have this html form which has options: <tr> <td width=30 height=35><font size=3>*List:</td> <td
I have written a simple CRUD form which has one select list. However the
I have a form which is a mdicontainer and has a menu strip at
I have a form in a Zend-based site which has a required Terms and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.