4 Replies Latest reply: Oct 31, 2014 6:42 AM by QuadrantProductions RSS

    Concatenate a loaded JSON URL

    QuadrantProductions Community Member

      If you have a JSON file that's being loaded (no problems there), and one of the JSON variables is named "thelink"  with a value of "http://www.somewebsite.com"

       

      How would you concatenate that in Animate.  Although the following syntax gave me back no error, it didn't work on a click.

       

      $.getJSON(myjson, function(data){

          {

                  sym.getSymbol("taboption2").click(function(){

              window.open((data[0].thelink), "_parent");})

          }

      });

        • 1. Re: Concatenate a loaded JSON URL
          QuadrantProductions Community Member

          My syntax appears to be off, but I cant tell where?


          window.open("('"+data[0].thelink+"')", "_parent")});

           

          The URL is in a JSON file that's being loaded as the JSON variable thelink

          Heres the full block.

           

           

          $.getJSON(myjson, function(data){

              {

                  var s1 = sym.getSymbol("taboption1");

                  s1.getSymbol("holder").$("placehere").css({"background-image":"url('"+data[0].image+"')"} );

                  s1.$("thename").html(data[0].thename);

                  //start mouse events//

                sym.getSymbol("taboption1").click(function(){

                  window.open("('"+data[0].thelink+"')", "_parent")});

              }

          });

          • 2. Re: Concatenate a loaded JSON URL
            vivekuma Adobe Employee

            I assume you have included the jQuery already.

             

            Syntax for window.open is wrong, it should be like this:   

               window.open("'"+data[0].thelink+"''", "_parent");

             

            and while adding click event, you should do like like:

                 sym.getSymbol("taboption1").getSymbolElement().click(function(){

             

            hth,

            Vivekuma

            • 3. Re: Concatenate a loaded JSON URL
              resdesign CommunityMVP

              I think for the click event you might want to use:

                sym.getSymbol("taboption1").getSymbolElement().bind("click",function() {

              • 4. Re: Concatenate a loaded JSON URL
                QuadrantProductions Community Member

                Thanks vivekuma,

                Close! There were a couple of extra ' in your string.  Also the correction on the click event didn't work.  The click on the entire symbol as per my original block of code did.  Just the sym.getSymbol("taboption1").click(function(){

                 

                The final syntax that worked at getting the data object from the JSON was as follows.  The only difference was I removed the ''s inside the " that were in your text.

                 

                window.open(""+data[0].thelink+"", "_parent");



                Thanks so much for your help!  Much appreciated.