2

I want to e.g. fetch the path /content/branc/region/microsite_name/en/mypage/jcr:content/par/mycomponent in jQuery.

I am able to fetch the page path using Granite.author.page.

Code to fetch page path:

(function ($, $document, author) {
    "use strict";   
$(document).on("dialog-ready", function() {
    var path = author.page`enter code here`.path; //This works
    var component = author.component.path; //This is not working
    console.log("component path " +component);
   });
})($, $(document), Granite.author);

Kindly advice how to fetch the component path in jquery.

Bernhard
  • 4,855
  • 5
  • 39
  • 70
Trupti
  • 23
  • 3

2 Answers2

1

The resourcetype is available in Granite.author.DialogFrame.currentDialog.editable.type. The path in the type field is not absolute and lacks the '/apps or /libs' part. If you are interested in the absolute path try Granite.author.DialogFrame.currentDialog.editable.config.dialog

Sharath Madappa
  • 3,393
  • 1
  • 24
  • 41
1

As @sharath-madappa points out, the resourceType is available from Granite.author.DialogFrame.currentDialog.editable.type.

If you want the exact path to the component that invoked the dialog, you can use Granite.author.DialogFrame.currentDialog.editable.path.

More documentation about it: https://helpx.adobe.com/experience-manager/6-3/sites/developing/using/reference-materials/jsdoc/ui-touch/editor-core/Granite.author.DialogFrame.html

jordivilagut
  • 333
  • 2
  • 9