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:
-
Get the JS files from jQuery and jQuery.Validation, save those to /Content/Js/ (or where ever).
-
Implement the IMonoRailContainerEvents and IMonoRailConfigurationEvents interfaces on my GlobalApplication.cs file.
-
In the Initialized method add:
IAjaxProxyGenerator ajaxProxyGenerator = new JQueryAjaxProxyGenerator();
container.ServiceInitializer.Initialize(ajaxProxyGenerator, container);
container.AjaxProxyGenerator = ajaxProxyGenerator;
- 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();
- 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>
- 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: