Click here to Skip to main content
Click here to Skip to main content
Articles » Web Development » Ajax » Libraries » Downloads
 
Add your own
alternative version

ensure - Ensure JavaScripts/HTML/CSS are loaded on-demand when needed

, 9 Jun 2008 CPOL
A tiny JavaScript library that provides a handy function "ensure" which allows you to load JavaScript, HTML, CSS on-demand and then execute your code. ensure ensures that relevant JavaScript and HTML snippets are already in the browser DOM before executing your code that uses them.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Popup.aspx.cs" Inherits="Components_Popup" %>

<div class="popup" style="display:none" id="Popup">
    <h1>This is a popup</h1>
    <p>As you see <em>ensure</em> loaded two snippet sets where one is for the fade effect in the background and another is for the popup box.</p>
    <p>The fade effect uses BlockUI.html, BlockUI.js</p>
    <p>The popup uses Popup.aspx and Popup.css</p>
    <p>
    <input type="button" value="Close" onclick="ensure({js:'Components/BlockUI.js'}, function(){ BlockUI.hide(); document.getElementById('Popup').style.display='none'})" />
    </p>
</div>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Omar Al Zabir
Architect BT, UK (ex British Telecom)
United Kingdom United Kingdom

| Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.141223.1 | Last Updated 9 Jun 2008
Article Copyright 2008 by Omar Al Zabir
Everything else Copyright © CodeProject, 1999-2014
Layout: fixed | fluid