Tales from the Evil Empire

Bertrand Le Roy's blog

News


Bertrand Le Roy

BoudinFatal's Gamercard

Tales from the Evil Empire - Blogged

Blogs I read

My other stuff

Archives

Microsoft Ajax Client Templates and declarative jQuery

Apparently Brian likes our declarative syntax. And jQuery. And he did something quite fun with them, something we had clearly not anticipated: using Microsoft Ajax’s new declarative syntax to call jQuery plug-ins instead of Microsoft Ajax behaviors as was the original intent.

<input type="text" maxlength="20" size="40" 
   sys:key=”self” 
   sys:attach=”wajbar”  
   wajbar:submit=”{{ $(self).next(’input:submit’) }}/> 

The way he made that possible is by adding a registration step to make the plug-in accessible through sys:attach. This registration API actually creates a wrapper behavior for the plug-in that gets Microsoft Ajax to believe the plug-in is a regular behavior. The actual plug-in gets called during initialization of the wrapper behavior, using the behavior itself as the options for the plug-in. This works because the declarative engine in Microsoft Ajax will just set plain expando fields for namespaced attributes such as “wajbar:submit” that don’t correspond to a property. Clever.

This is quite interesting and opens up a number of possibilities, such as enabling our declarative syntax to instantiate components from any framework (without the hack of wrapping them in a Microsoft Ajax behavior) if we open up the right extensibility points. This is definitely something I’ll investigate.

What do you think?

Brian’s post:
http://weblogs.manas.com.ar/bcardiff/2008/12/declarative-jquery-with-microsoft-ajax/

Comments

Dave Ward said:

What happens when your designer runs those expando attributes through Dreamweaver or who-knows-what on their Mac?  I understand that they are technically unobtrusive in theory, but I don't think they'd work as well as the standard jQuery wireups in practice.

What he did is neat though, nevertheless.

# December 10, 2008 2:50 AM

Mike said:

"What do you think?"

Great!

# December 10, 2008 4:25 AM

Andy said:

Yes please, allowing adding jQuery plugins declaratively seems a must. I can imagine it would become a common Wish List item on the ASP.NET forums if this isn't added. Especially as jQuery UI and Layout scripts gain momentum. And would really justify all the positive press around using jQuery.

# December 10, 2008 6:21 AM

James said:

In the next version of ASP.NET AJAX, can you please provide hosted support for the libraries like Google does with JQuery.  These ASP.NET AJAX are large and slow. Would be great if they were hosted on Microsoft's servers.

Thanks.

# December 10, 2008 1:55 PM

Bertrand Le Roy said:

@James: yes, I'm working on that. But I'd be interested in knowing where that perception that our libraries are "large and slow" comes from. MicrosoftAjax.js is 22kB on the wire, and the framework is optimized for fast loading. Can you send me mail at bleroy at microsoft so we can chat?

# December 10, 2008 4:17 PM