0 Replies Latest reply on Jan 12, 2013 8:25 PM by jomariworks

    injecting json files to replace text

    jomariworks Level 1

      I've created a site that injects text into a symbol when you click on another symbol.


      Not being a programmer by profession, I've come up with a kludge that accomplishes the goal, but I'd love to have someone explain the proper way to do this.


      I'm using http://json.fastfrag.org/ to convert html tables to json files and then using fastfrag js to convert the json file back into an html object.


      The existing content in a hidden div is set to nothing because I couldn't figure out how to replace the existing html. (I could only get append to work)


      New html content is appended into a hidden div so that I can determine the height of the new content.


      The new height of the hidden div is used to adjust the height of the Stage to accommodate the new html.


      The final destination symbol is loaded and then the TextBox content is replaced with the html from the hidden div.


      Here's the code:


      $.getJSON('mapLinkStockton.json', function(data) {

                           //fastFraq converts json to html object

                          var newHTML =fastFrag.create(data[0]);

                          //get hidden div datasize

                          var datasize = document.querySelector('#datasize');

                          //empty div


                          //append fastFraq object


                          //get the height for the hidden div

                          divHeight = $('#datasize').height();

                          //had photo height and padding to create new stage height

                          newHeight = divHeight+600+'px';

                          //adjust stage height


                            //get html from datasize div

                          var replaceHTML = $('#datasize').html();

                          //get the maptext symbol

                          var mySymbolObject = sym.getSymbol("mapTextSym");

                          // substitute mapDataTextBox content with region html




      You can see this in action at  http://www.jomariworks.com/edge-json/map.html  Only the links in Hawaii, California, Oregon and Washington are live.


      Projects files can be downloaded at http://www.jomariworks.com/edge-json/edge-json.zip


      In addition to cleaning up this code, I was wondering how I would set up a function that would be available so that all I would have to do is supply the name of the json file.


      Thanks in advance for any help with this.