0 Replies Latest reply on Sep 2, 2013 6:58 AM by Chris Lhaut

    How to display second element from json file in EA ?

    Chris Lhaut Level 1

      Hello,

       

      I'm looking to do sommething with json datas. I used a script using Edge commons that shows how to load json datas.

      the problem is that it loads all the elements from my Json file. For example, here is my structure:

       

      [

      {

          "title": "test",

          "description": "my description",

          "spotlight": "images/img00.jpg"

      },

      {

          "title": "title 2",

          "description": "Here my second desc",

          "spotlight": "images/img01.jpg"

      },

      {

          "title": "title3",

          "description": "Here is another desc",

          "spotlight": "images/img03.jpg"

      }

      ]

       

      and this is how it loads in my Edge file:

       

      yepnope({

      load: [

      "http://cdn.edgecommons.org/an/1.0.0/js/min/EdgeCommons.js"

      ],

      complete: function() {

      EC.debug("Ready to go!");

      }

      });

       

      // get JSON file

      $.getJSON("content.json")

      .success(

      function(data){

      console.log("incoming data: ", data);

      $.each(data, function(index, item){

      var s = sym.createChildSymbol( "txt_content" , "txt_content" );

      s.$("title_featured").html( item.title );

      s.$("txt_featured").html( item.description );

      s.$("spotlight").html( '<img src="images/'+item.spotlight+'" width="418px" height="227px" />' );

       

      s.play(index * -500);

       

      s.setVariable( "spotlight" , item.spotlight );

       

      });

      }

      );

       

       

      All my elements load in my file but how can I do if for example I want to display ONLY the second element ?

       

      Can someone help me please? it's for sure not hard to do but I'm looking for the solutions for a few days now :/

       

       

      Thanks for the answers !

       

      Chris