JQuery fallback script

It’s possible that a CDN may become unavailable to your web application, if so you’ll want to fallback to another source for your libraries (JQuery in this example).

    <script type="text/javascript">
        if (typeof jQuery == 'undefined') {
            var e = document.createElement('script');
            e.src = [email protected]("~/Content/js/jQuery/jquery-1.11.1.min.js")';
            e.type = 'text/javascript';
            document.getElementsByTagName("head")[0].appendChild(e);
        }
    </script>

Gator.js a micro event handling framework

I’ve had a look at gator.js, it’s useful because it’s very a lightweight way of handling events on page elements. Quick demo below:

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Gator demo</title>
      <script type="text/javascript" src="gator.min.js"></script>
</head>
<body>
     <table id="mytable">
        <tr>
            <td>A</td>
            <td>1</td>
        </tr>
        <tr>
            <td>B</td>
            <td>2</td>
        </tr>
        <tr>
            <td>C</td>
            <td>3</td>
        </tr>
        <tr>
            <td>D</td>
            <td>4</td>
        </tr>
        <tr>
            <td>E</td>
            <td>5</td>
        </tr>
    </table>
    <script type="text/javascript">
        var table = document.getElementById("mytable");
     
        Gator(table).on('click', 'tr', function (e) {
            alert("clicked on table row");
        });
    </script>
</body>
</html>