Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Check asset status (publish/unpublished) in Asset Finder on Page load (AEM 6.2)

Avatar

Avatar
Validate 25
MVP
Himanshu_Singhal
MVP

Likes

65 likes

Total Posts

206 posts

Correct Reply

23 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 25
MVP
Himanshu_Singhal
MVP

Likes

65 likes

Total Posts

206 posts

Correct Reply

23 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 5
Give Back 3
View profile
Himanshu_Singhal
MVP

01-01-2019

Hi,

I've a requirement where it's required to check the Publish status to Published on component dialog open in AEM 6.2

asset_finder.PNG

I've tried checking the DOM changes on click on but I don't see the value e.g. checked=true getting added in the input field or not able to find how should perform click event pragmatically on radio button here?

Could anyone help me regarding this?

Regards,
Himanshu Singhal

Replies

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

01-01-2019

Try this

(function ($, $document, author) {

    "use strict";

    $document.on('foundation-contentloaded', onAssetFinderLoad);

    function onAssetFinderLoad(){

        $.ajax(author.page.path+ "/jcr:content.json").done(checkStatus);

   }

    function checkStatus (data){

        var q = data["cq:lastReplicationAction"];

        if(q && q == "Activate"){

            $( "input[type=radio][value=Activate]")[0].checked = true;  // use a different selector for radio buttons in case of a conflict/customization

           $( "input[type=radio][value=Deactivate]")[0].checked = false;

        }

        else {

          $( "input[type=radio][value=Activate]")[0].checked = false;

          $( "input[type=radio][value=Deactivate]")[0].checked = true;

        }

    }

})($, $(document), Granite.author);

Add it under 'cq.authoring.dialog' category.

**This is just a sample code and not tested properly. Extend/Modify it per your use case to make it more specific.

Avatar

Avatar
Validate 25
MVP
Himanshu_Singhal
MVP

Likes

65 likes

Total Posts

206 posts

Correct Reply

23 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 5
Give Back 3
View profile

Avatar
Validate 25
MVP
Himanshu_Singhal
MVP

Likes

65 likes

Total Posts

206 posts

Correct Reply

23 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give Back 5
Give Back 3
View profile
Himanshu_Singhal
MVP

02-01-2019

Hi Gaurav,

Thanks for the code.

The code I made it work as per the requirement. But, what's happening is when I try to check the radio button using JavaScript/jQuery, that part is working fine as it's checking the radio button but when I try to trigger click event then it has no effect and nothing appears in the filter. However, if we click on radio button physically(manual click) then it appears in the filter.

Any idea?

Avatar

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile

Avatar
Validate 25
MVP
bsloki
MVP

Likes

182 likes

Total Posts

1,859 posts

Correct Reply

545 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Boost 50
Boost 5
View profile
bsloki
MVP

02-01-2019

You need to call this javascript on a click event of the radio button.

Avatar

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile

Avatar
Give back 300
MVP
Gaurav-Behl
MVP

Likes

243 likes

Total Posts

1,145 posts

Correct Reply

281 solutions
Top badges earned
Give back 300
Give Back 50
Give Back 5
Give Back 3
Give Back 25
View profile
Gaurav-Behl
MVP

02-01-2019

Did you use http://api.jquery.com/trigger/ to trigger the click event or some other way?

Did you apply debug breakpoint or check console logs to see if the issue is with trigger event or otherwise with code? Do you see modified DOM after the trigger event has finished processing?

Can you test the same code in different browser to rule out any issues with your source code?

Can you share the code that is not working?