Get property of parent par inside child component's dialog | Community
Skip to main content
Level 5
October 16, 2015
Solved

Get property of parent par inside child component's dialog

  • October 16, 2015
  • 3 replies
  • 2645 views

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

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 Premkarthic-7WP

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

3 replies

Premkarthic-7WP
Premkarthic-7WPAccepted solution
Level 4
October 16, 2015

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

vdhim23Author
Level 5
October 16, 2015

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. }
Premkarthic-7WP
Level 4
October 16, 2015

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