AnsweredAssumed Answered

How to Include JQuery source code in web viewer calculation

Question asked by macrolide on Sep 27, 2016
Latest reply on Sep 28, 2016 by beverly

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.

Outcomes