Should HTML DOM IDs be hard-coded throughout a Rails app, or stored
within..an appropriate model or helper or ..?

Here's an example problem:

/neighbourhoods/1/map/ has a form:
  # map.html.erb
  <% form_remote_tag ... :html => {:id => 'map-filter-form'} do %>

When the page loads, the form needs to be submitted:
  # public/javascript/submit_map_filter_form.js
  Event.observe(window, 'load', function() {
    $('map-filter-form').onsubmit();
    });

Thus, I include the Javascript file mentioned above:
  # map.html.erb
  <%= javascript_include_tag 'submit_map_filter_form' %>

This feels wrong because the form's DOM ID ("map-filter-form") is hard-
coded in multiple locations (the view, and the Javascript file). As I
add functionality that uses the form, the number of places where the
form's DOM ID is hardcoded will increase.

Does anyone have suggestions or comments for how to deal with this?

Cheers,
Nick
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to