On Friday 18 November 2005 10:58 pm, John Lam wrote:> I was wondering if there was any support a''la observe_field for
capturing
> arbitrary events and triggering an AJAX postback.
Add some JavaScript triggers?:
http://www.alistapart.com/articles/scripttriggers/
(A List Apart''s CMS is actually powered by Rails)
Rails leans towards beautiful rhtml, but the observe_field helper drops
javascript bang in the middle of your html. MVC is one thing, but for
separate presentation, behavioural, and structural layers on the browser side
of things, try the JavaScript triggers article and the excellent accessible
pop-up links article:
http://www.alistapart.com/articles/popuplinks/
To apply this to rails, the prototype library gives you
$(''element_id'') to
supplant the getElementById function used in the articles, and you can either
place your triggers in an external JS file and link it in with a
javascript_include_tag in your layout, or use
<script type="text/javascript"><%= @content_for_page_scripts
%></script>
in your layout and
<% content_for("page_scripts") do -%>
/* insert JS here */
<% end -%>
in your templates to customise events by controller/action.
Maybe examine the code generated by the observe_field helper and apply some A
List Apart goodness to it. Haven''t tried it personally, but am meaning
to do
so in the near future... Any comments Mr Dan Benjamin?
http://www.alistapart.com/authors/b/danbenjamin/
--
Mark Beattie
Easy Schedule Management
http://easy-online-schedule.com