ermouth / jQuery.my

jQuery.my is a plugin that reactively binds form controls with js data structures.
https://jquerymy.com
1.51k stars 114 forks source link

[how to] iterate in array without a parent #28

Closed majorebola closed 8 years ago

majorebola commented 8 years ago

I'm sorry for asking you this question here but I didn't found a better place.

I've been perfectly able to use jquerymy with a pretty complex data like this one

  "parent": {
    "property_one": "value_1",
    "list": [
      {
        "name": "1",
        "desc": "one",
        "sublist": [
          {
            "name": "wow",
            "value": "80"
          },
          {
            "name": "more wow",
            "value": "60"
          }
         ]
      },
      {
        "name": "2",
        "desc": "two",
        "sublist": [
          {
            "name": "wow",
            "value": "80"
          },
          {
            "name": "more wow",
            "value": "60"
          }
         ]
      }
]
}

But I cannot use correctly jquerymy with a "simpler" version

  "parent": [
      {
        "name": "1",
        "desc": "one",
        "sublist": [
          {
            "name": "wow",
            "value": "80"
          },
          {
            "name": "more wow",
            "value": "60"
          }
         ]
      },
      {
        "name": "2",
        "desc": "two",
        "sublist": [
          {
            "name": "wow",
            "value": "80"
          },
          {
            "name": "more wow",
            "value": "60"
          }
         ]
      }
]

I tried a couple of things in the manifest. I read the docs about this but I feel guilty I didnt' get how to do it.

I am probably just blind and not able to see something supersimple, what am I missing?

PS: TY for fixing so quickly the other problem.

ermouth commented 8 years ago

If I understood correctly, you pass an array as a data source. Root data source must be an object, arrays are only allowed as branches for several reasons.

majorebola commented 8 years ago

Exactly. Ok. I was thinking I missed smth.

TY very much