Profile picture Schedule a Meeting
c a n d l a n d . n e t

Changes Needed for Castle.MonoRail to use jQuery

Dusty Candland | |

To get jQuery as the JS library for monorail I need to do the following:

  1. Get the JS files from jQuery and jQuery.Validation, save those to /Content/Js/ (or where ever).

  2. Implement the IMonoRailContainerEvents and IMonoRailConfigurationEvents interfaces on my GlobalApplication.cs file.

  3. In the Initialized method add:

IAjaxProxyGenerator ajaxProxyGenerator = new JQueryAjaxProxyGenerator();
container.ServiceInitializer.Initialize(ajaxProxyGenerator, container);
container.AjaxProxyGenerator = ajaxProxyGenerator;
  1. In the Configure method add:
configuration.JSGeneratorConfiguration.AddLibrary("jquery-1.2.1", typeof(JQueryGenerator))
    .AddExtension(typeof(CommonJSExtension))
    .ElementGenerator
        .AddExtension(typeof(JQueryElementGenerator))
        .Done
    .BrowserValidatorIs(typeof(JQueryValidator))
    .SetAsDefault();
  1. In the layout file reference the JS files like:
<script language="javascript" type="text/javascript" src="${siteRoot}/Content/Js/jquery-1.2.6.min.js"></script>
<script language="javascript" type="text/javascript" src="${siteRoot}/Content/Js/jquery.validate.min.js"></script>

  1. Use the Castle trunk source.

References:

http://hammett.castleproject.org/?p=238

http://groups.google.co.nz/group/castle-project-users/browse_thread/thread/eb5bb0e5b4560a97

http://endurotracker.blogspot.com/2008/09/jquery-and-monorail.html

http://www.nabble.com/jquery-proxy-generator-in-trunk-td19670846.html

Webmentions

These are webmentions via the IndieWeb and webmention.io. Mention this post from your site: