Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.
SOLVED

Update using javascript for coral touch ui date picker to show date based on classic ui data

Avatar

Level 8

Hi,

I have to  show the retrieved date data  from crxde which was saved using classic ui dialog  using javascript to  granite/ui/components/coral/foundation/form/datepicker

The data when i retrieved  in javascript comes up as

"Thu Jul 25 2019 12:48:00 GMT+0530"

Now i need to pass this data to coral datepicker  using javascript .

Any inputs or sample code as how i could achieve it

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 8

I was trying to read the pageproperties using ajax query to pagepath/jcr:content.json  this was sending request in the above format.

I changed the ajax query to point to servelt and send it back to ajax request and solved the issue

Component dialog details of the field

<Date

         jcr:primaryType="nt:unstructured"

         granite:class=".cq-dialog-field-filldata-parentnode-data"

        

         sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"

         granite:id="datecompId"

         displayedFormat="MMMM DD, YYYY hh:mm a"

         displayTimezoneMessage="{Boolean}true"

         type="datetime"

         fieldLabel="Date"

         name="../../releaseDate">

        </Date>

Step2:-

I created a ajax request based on

Send a Ajax request to servlet

var requestPathWithHtml = $(".foundation-content-path").data("foundationContentPath");

        var requestPath=requestPathWithHtml.replace(/\.[^/.]+$/, "");

  $.ajax({

            type: "GET",

            url: "/bin/requreidserveltpath",

  data:{"pagepath":requestPath},

  contentType: "application/json"

        }).success(function (res) {

$("#datecompId").val(res["pressReleaseDate"]);

}

View solution in original post

1 Reply

Avatar

Correct answer by
Level 8

I was trying to read the pageproperties using ajax query to pagepath/jcr:content.json  this was sending request in the above format.

I changed the ajax query to point to servelt and send it back to ajax request and solved the issue

Component dialog details of the field

<Date

         jcr:primaryType="nt:unstructured"

         granite:class=".cq-dialog-field-filldata-parentnode-data"

        

         sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"

         granite:id="datecompId"

         displayedFormat="MMMM DD, YYYY hh:mm a"

         displayTimezoneMessage="{Boolean}true"

         type="datetime"

         fieldLabel="Date"

         name="../../releaseDate">

        </Date>

Step2:-

I created a ajax request based on

Send a Ajax request to servlet

var requestPathWithHtml = $(".foundation-content-path").data("foundationContentPath");

        var requestPath=requestPathWithHtml.replace(/\.[^/.]+$/, "");

  $.ajax({

            type: "GET",

            url: "/bin/requreidserveltpath",

  data:{"pagepath":requestPath},

  contentType: "application/json"

        }).success(function (res) {

$("#datecompId").val(res["pressReleaseDate"]);

}