1 2 Previous Next 15 Replies Latest reply on Sep 28, 2016 3:09 AM by beverly

    How to Include JQuery source code in web viewer calculation

    macrolide

      FMP Advanced 13 on OS X Yosemite

      -------------------------------------------

       

      [Edit: Typos corrected]

       

      I have a web viewer that renders html content from a field.

       

      Wanted to add some basic interactivity with JQuery. Instead of linking to a CDN, I am storing jquery.min.js in a global field so I can get it to work when offline.

       

      The Webviewer calculation is:

      "data:text/html,"

      & "<HTML><HEAD>"  

      & ¶ & "<STYLE>" & Includes::myStyles_css & "</STYLE>"

      & ¶ & "</HEAD><BODY>"

      & ¶ & "<div class=\"section\">" &  Articles::Text & "</div>"

      & ¶ & "<SCRIPT>"  &  Lib::jQuery_src    &  "</SCRIPT>"

      & ¶ & "<SCRIPT>"  &  Articles::my_javascript &  "</SCRIPT>"

      & ¶ & "</BODY></HTML>"

       

      Articles::Text contains the following code:

       

      <div>

      <p>Some text<span class="result">150 votes</span>

      <button id="show-result">Show Results</button>

      </div>

       

      Articles::my_javascript contains the following code:

       

      $("button#show-result").click(function() {

      $(".result").toggleClass("show-result");

      });

       

      Includes::myStyles_css contains the following

       

      .result{

      visibility:hidden;

      }

       

      .show-result{

      visibility:visible

      }

       

      How can I make this work ?

       

      Corrected Typos.

        1 2 Previous Next