0

I have this code in js, on click this happens:

  var self = $(this);
  self.click(function(e){
    e.preventDefault();

    var nid = self.parents('.innerContainer').attr('nid');
    var subjectTitleNID =  settings.xxxxx.yyyy["nid-" + nid]

Via HTML I can find the NID value of InnerContainer, which is the main parent.
From the console, if I run Drupal.settings.xxxx.yyyyy (where xxxx and yyyy are my destinations), I get a list of objects which are children.
["nid-463"]
["nid-465"]
["nid-466"] etc ....

nid-466 is the value assigned to VAR NID.

But what I need to find now, is:
1. How many children there are in ["nid-466"]
2. What are their values

Usually I would run a simple for loop, but I don't know how to target those values.

For example, I would do this:

for (i=0; i < dont know what to put here .length; i++) {
    > Drupal.settings.xxxx.yyyy[nid-466][nid-??]  // this is incorrect
    }

See image for more detailed structure.

Object Structure

Any ideas? Thanks George

1
  • You loop through Drupal.settings.xxxx.yyyy[nid-466] again and get the keys and values Commented Sep 19, 2014 at 11:51

1 Answer 1

1

Use $.each loor for this:

$.each(Drupal.settings.xxxx.yyyy[nid-466], function(index, value) {
    // index is a key 
    // value is a object
    // put your code here 
    // console.log(value.nid);
})
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.