Expand my Community achievements bar.

SOLVED

Get property of parent par inside child component's dialog

Avatar

Level 5

Hi

I have a component which i drop, creates a parsys. Inside that parsys i drop another component sat compo2. I want to achive when i load the dialog for compo2, it will fetch the value of component & on the basis of this some functionality to be perform in dialog. Below is the listener in compo2 dialog.

loadContent : function(dialog) { var path = // path of component if(path == 'landing') { console.log("Inside IF"); dialog.findByType('tabpanel')[0].hideTabStripItem(1); } }

Under content hierarchy will be   ....../component/par/compo2 and I want to fetch some node's property inside load content.

Thanks

1 Accepted Solution

Avatar

Correct answer by
Level 4

Hi,

you can get the path of current node inside loadcontent listener as like,

function(dialog){

var compPath = dialog.path;

var data = CQ.Util.eval(CQ.HTTP.get(path.json));

//iterate the data to get your required value.

},

If you want the parent node value then can you manipulate the same using currentnode path.

Hope this will work for you.

 

Thanks,

Karthi

View solution in original post

3 Replies

Avatar

Correct answer by
Level 4

Hi,

you can get the path of current node inside loadcontent listener as like,

function(dialog){

var compPath = dialog.path;

var data = CQ.Util.eval(CQ.HTTP.get(path.json));

//iterate the data to get your required value.

},

If you want the parent node value then can you manipulate the same using currentnode path.

Hope this will work for you.

 

Thanks,

Karthi

Avatar

Level 5

KarthiCQ5 wrote...

Hi,

you can get the path of current node inside loadcontent listener as like,

function(dialog){

var compPath = dialog.path;

var data = CQ.Util.eval(CQ.HTTP.get(path.json));

//iterate the data to get your required value.

},

If you want the parent node value then can you manipulate the same using currentnode path.

Hope this will work for you.

 

Thanks,

Karthi

 

 

 

 

KarthiCQ5 wrote...

Hi,

you can get the path of current node inside loadcontent listener as like,

function(dialog){

var compPath = dialog.path;

var data = CQ.Util.eval(CQ.HTTP.get(path.json));

//iterate the data to get your required value.

},

If you want the parent node value then can you manipulate the same using currentnode path.

Hope this will work for you.

 

Thanks,

Karthi

 

 

 

 

Hi I am getting the below error : Uncaught TypeError: Cannot read property 'indexOf' of undefined . I applied the below code 

function(dialog) { var compPath = dialog.path; console.log("compPath ::: "+compPath); var data = CQ.Util.eval(CQ.HTTP.get(compPath.json)); console.log("data ::: "+data); //iterate the data to get your required value. }

Avatar

Level 4

in line 5

use as below,

var data = CQ.Util.eval(CQ.HTTP.get(compPath+".json"));

Mind the quotes around the ".json" as that it was string and also +.

Sorry, I missed that same on while providing the sample code.

You will get the json as response. You can iterate the same to get your required value.

 

Thanks,

Karthi