How to display Saving when click the Create button if not finish? | Community
Skip to main content
bhoang
Level 4
October 25, 2018
Solved

How to display Saving when click the Create button if not finish?

  • October 25, 2018
  • 5 replies
  • 2686 views

Hi,

When I create a property page, input the content and click the Create button. The aem save very slow, the user don't understand it saving. So they click again on the Create button. After that the aem save two time and the content is duplicate (it create two page content). I want to display the gif file (example Saving or Creating) it will showing when click on the Create button for the user know and waiting for create finish.

How to do that?

Thanks & Best regards,

BienHV

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by arunpatidar

Below code should work:

Clientlib category - granite.ui.coral.foundation

/* JS Code  to disable create button*/

(function(document, $) {

  $( document ).ready(function() {

        console.log( "ready!" );

        var formSelector = "form.cq-siteadmin-admin-createpage";

        var selector = "form.cq-siteadmin-admin-createpage .foundation-layout-wizard2-header .coral-Panel button[type=submit]";

        var selectorBtn = "coral-dialog.coral-Dialog.coral-Dialog--success.is-open>div.coral-Dialog-wrapper>coral-dialog-footer>button";

       

        $(formSelector).on('submit', function() {

            $(selector).attr("disabled", "disabled");

            console.log("button disabled");

        });

        $("body").on('click', selectorBtn, function() {

            $(selector).removeAttr("disabled");

            console.log("button enabled");

        });

    });

})(document, Granite.$);

5 replies

arunpatidar
Community Advisor
Community Advisor
October 30, 2018

Hi,

You can disabled Create button once clicked and enable it again as soon as page created and OOTB popup displayed.

in popup there are two buttons, open and done. on click of any button you can enabled create button again. Thats how you can prevent duplicate page creation.

Arun Patidar
bhoang
bhoangAuthor
Level 4
October 31, 2018

Last week I tried disabled Create button when clicked and enabled it again as soon as page created. However, it work fine with save button, but it not right for Create button.

arunpatidar
Community Advisor
Community Advisor
October 31, 2018

I'll try same and get back to you.

Arun Patidar
bhoang
bhoangAuthor
Level 4
October 31, 2018

Thanks you,

I am hearing from you.

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
November 3, 2018

Below code should work:

Clientlib category - granite.ui.coral.foundation

/* JS Code  to disable create button*/

(function(document, $) {

  $( document ).ready(function() {

        console.log( "ready!" );

        var formSelector = "form.cq-siteadmin-admin-createpage";

        var selector = "form.cq-siteadmin-admin-createpage .foundation-layout-wizard2-header .coral-Panel button[type=submit]";

        var selectorBtn = "coral-dialog.coral-Dialog.coral-Dialog--success.is-open>div.coral-Dialog-wrapper>coral-dialog-footer>button";

       

        $(formSelector).on('submit', function() {

            $(selector).attr("disabled", "disabled");

            console.log("button disabled");

        });

        $("body").on('click', selectorBtn, function() {

            $(selector).removeAttr("disabled");

            console.log("button enabled");

        });

    });

})(document, Granite.$);

Arun Patidar