Loading Scripts As Strings into the DOM with JQuery

Here’s why JavaScript is teh awsome: var ns = {}; $(document).ready(function () { $(‘<scrip’+’t>ns.blah=function(){alert(“hi”);};</scr’+’ipt>’) .appendTo(‘body’); ns.blah(); }); With this I get: Here play with it yourself. http://www.jsfiddle.net/nVuNZ/ Consider the deployment and update scenarios enabled using this technique with a modular application pattern.

DataBinding JS Objects Into HTML Forms With jquery-datalink and jquery-tmpl

Till now chain.js has been my favorite light touch templating and data-linking library. Today finally the official JQuery templating, data-linking, and globalization plugins are here. The new plugins are very simple to use and nicely fill 2 very important gaps that really needed officially supported solutions, namely templating and datalinking. I’ll show you a little bit of theContinue reading “DataBinding JS Objects Into HTML Forms With jquery-datalink and jquery-tmpl”

ColdFusion and onMissingMethod – Tapping The Hidden Power

Recently I had to do some work in ColdFusion.  In the midst of the pain, imagine my surprise and delight to find that CF components support a dynamic dispatch construct. While unsightly, you can create wormholes and drop call routing through them It works like this.  When you attempt a method call against a .cfcContinue reading “ColdFusion and onMissingMethod – Tapping The Hidden Power”

Fat-Free Templating with Barebones Javascript

Today I’m going to demonstrate a straight-forward and very effective technique for markup templating.  I’ve borrowed the supplant prototype function from Douglas Crockford’s – And Then There Was Javascript presentation, in order to show you how to inject values from custom data structures directly into into strings.  We’ll be doing a minimal implementation here inContinue reading “Fat-Free Templating with Barebones Javascript”

Implementing method_missing with C# dynamic – Part 2

In my previous post, Implementing method_missing with C# dynamic – Part 1, I demonstrated a simple approach to plugging a method_missing call routing seam into a DynamicObject.  Here I’ll take it a step further to implement a generic method_missing function capable of passing any call to a forwarding context object.  Note that I do notContinue reading “Implementing method_missing with C# dynamic – Part 2”

Implementing method_missing with C# dynamic – Part 1

One of the neat things about Ruby is its method_missing fallback capability.  Using the C# 4.0 DynamicObject, we’re also able to control dispatch at runtime.  I wanted to see how the method_missing idiom might work with a C# dynamic dispatcher, so I wrote up a small sample. [TestMethod] public void Can_Control_Dynamic_Dispatch() {     dynamic dispatcher1Continue reading “Implementing method_missing with C# dynamic – Part 1”

A Small Javascript To Safely Load Scripts and Styles Into The DOM

Consider scenarios where you have pages composed of parts that are combined at runtime.  If the many authors of those parts have external script references sprinkeled throughout, there is the chance that author2 might over write author1’s reference of JQuery or some other script dependency.  The consequences of doing this are usually breakage.  I wrote this little script toContinue reading “A Small Javascript To Safely Load Scripts and Styles Into The DOM”

Property Copying With Dynamic Objects in .NET 4.0

Lately, I’ve been trying out some of the new .NET 4.0 language features.  Specifically, I’ve been looking into ways to trivially combine late dispatch and late binding in order to build general purpose convenience objects.   In this case, I wanted an expando object that I could program against with some of the techniques we use in javascript to programmatically build up aContinue reading “Property Copying With Dynamic Objects in .NET 4.0”

Using JQuery With WebForms Controls

The scenario:  We have an ASP.NET CheckListBox from which we want to ensure at least one option has been selected before allowing the user to click a button.  Sounds simple enough, but we’re going to use JQuery to do all of this work on the client.    ASP.NET MARKUP: <%@ Control Language="C#" AutoEventWireup="true" CodeBehind="FileDownloadUserControl.ascx.cs" Inherits="FileDownloadUserControl"Continue reading “Using JQuery With WebForms Controls”