Incorporating jQuery in Applications

I finally got External libraries to work in my applications. Now I am moving onto working with jQuery. I want to understand how to code to include various jQuery functions. For most Scriptcase applications there is a ScriptInit section, but for BLANK applications there is none, just onExecute.

Once I load the library I select the option to “Use Library” and then save the settings.

For jBox here is the Basics thay lay out:
<script src=“https://code.jquery.com/jquery-3.3.1.min.js”></script> <script src=“https://cdn.jsdelivr.net/gh/StephanWagner/jBox@v0.6.2/dist/jBox.all.min.js”></script> <link href=“https://cdn.jsdelivr.net/gh/StephanWagner/jBox@v0.6.2/dist/jBox.all.min.css” rel=“stylesheet”> So ifor all application types except for BLANK I place the above code in ScriptInit?
Do I add ‘echo’ before these lines with double quotes and change the other quotes to single marks?

A blank app is exactly that; blank. No HTTP headers have been sent, it’s basically like starting a blank .PHP file on any server with the exception of all the Scriptcase macros and database connection working non-verbose in the background. So, if you want jQuery - either include it from the official jQuery website and add it to your header - or download it from a repository and put it somewhere in your external libraries. You could even copy/past the link (be sure to make it relative) from any other Scriptcase app’s sourcecode, as jQuery is included.

So, if you want to add the <script> tags, do as you’d normally do in any other PHP file.

Regular PHP file


<?php

# Do PHP stuff here

?>  <!--break out of PHP, were in HTML now; hence the HTML style comment -->

<!-- do HTML stuff -->

<?php

# Now we're back in PHP
# No closing tag; never close PHP files at the very end

Source code in blank Scriptcase app


$foo = "Hello world!"; // regular PHP

?> <!-- break out of PHP and now you can do HTML/JS/CSS stuff -->

<html>
    <header>
        <title>Your app</title>
        <script type="text/javascript" src="http://www.url.com/javascript.js"></script>
    </header>
    <body>
        <div>HTML text here</div>
        <div><?php echo "Some PHP text here:" . $foo; ?></div>
    </body>
</html>

<?php

# Absolutely do a closing tag to get get back into PHP, so Scriptcase can go on an do it's business.

1 Like