7 Replies Latest reply on Nov 19, 2016 6:17 AM by jordan.van.bergen@copaco.com

    How to use configstring value inside view.html?

    jordan.van.bergen@copaco.com

      I made the internal custom view app + config.

       

      You get the following view.js part:

       

      function onReady(tileConfig,tileOptions,viewer,container) {

        $("#config_string").text(tileConfig["configString"]);

        app.resize();

      } // end function

       

      This is working nicely.

       

      But I want to use this value text(tileConfig["configString"] in my own javascript inside the view.html file (/public/view.html).

       

      I can't seem to use it currently. It's not read. Can somebody explain:

       

      1. If this value text(tileConfig["configString"] can be used in your own /public/view.html ????

      2. How to do it?

        • Re: How to use configstring value inside view.html?

          Is the line $('#config_string).text(tileConfig["configString"]) not read or is the tileConfig.configString parameter returning undefined?

          • If it's undefined, you'll need to go to the configuration page and make sure to save the configuration (e.g.: jive.tile.close({'data':{'configString' : "this is a string"}}), tileOptions     ). Notice that the configuration page keeps the configString object inside the "data" parameter. The view reads it as just tileConfig.configString.
          • If it's not being read, check your main.js file is being loaded by view.html. That file contains the init function that will eventually call the onReady function and pass in the tile config, options, viewer, container.
            • Re: How to use configstring value inside view.html?
              jordan.van.bergen@copaco.com

              In view.html I get:

               

              1. Is the line $('#config_string).text(tileConfig["configString"]) not read


              If I have this in view.html: $("#config_string").text(config["configString"]);
              I get:

               

              2. or is the tileConfig.configString parameter returning undefined?

               

              If I have this in view.html:      $("#config_string").text(tileConfig.configString);

              I get:

               

              If I do it in view.js it's working.

               

              Then you say:

              • If it's undefined, you'll need to go to the configuration page and make sure to save the configuration (e.g.: jive.tile.close({'data':{'configString' : "this is a string"}}), tileOptions     ).


              You talk about the configuration page. I would like to know about what file you are talking? Everything works with the files so I don't look at pages. I develop in files. So where should I put (e.g.: jive.tile.close({'data':{'configString' : "this is a string"}}), tileOptions     ) to make tileConfig.configString available to the view.html file?

                • Re: How to use configstring value inside view.html?
                  npanta@italentcorp.com

                  I also got the 1st error what you are getting. I resolved by changing the text in configuration.js (line number:17) inside onReady function second if condition

                   

                  config["data"] = { };    to    tileConfig["data"] = { };

                   

                  Hope this helps,

                   

                  Narsi.

                  • Re: How to use configstring value inside view.html?

                    Jordan van Bergen wrote:

                     

                    In view.html I get:

                     

                    1. Is the line $('#config_string).text(tileConfig["configString"]) not read


                    If I have this in view.html: $("#config_string").text(config["configString"]);
                    I get:

                    This won't work because there is no "config" object. Your onReady function would pass in the arguments (tileConfig, tileOptions, viewer, container). It would need to be .text(tileConfig["configString"]). Like you did in the next part.

                     

                     

                    2. or is the tileConfig.configString parameter returning undefined?

                     

                    If I have this in view.html: $("#config_string").text(tileConfig.configString);

                    I get:

                     

                    If I do it in view.js it's working.

                    DIdn't see this at first about using the view.html. You should be having those functions be called in your view.js. If you want to not use the view.js file (any particular reasons why—since you're keeping the main.js?), you'll need to put these scripts at the end of your HTML so the main.js can open and execute first.

                     

                    OR

                     

                    You can get rid of both the main.js and view.js files by putting this:

                    <script>
                         jive.tile.onOpen((tileConfig, tileOptions) =>{
                              $('#config_string').text(tileConfig.configString);
                              gadets.window.adjustHeight();   
                         })
                    </script>
                    

                     

                    We included the main.js, view.js, and configuration.js files in the SDK to help understand and provide methods of calling our API's more intuitive. Please look through the main.js file and see how the calls flow...I believe this will help your understanding greatly.

                    1 person found this helpful