When it comes to HTML... it''s kind of hard to not... hard-code it. Either you end up having some dictionary that is a pain to manage or you just have good conventions. This is what we do at Planet Argon to keep things a bit more organized. * http://www.robbyonrails.com/articles/2007/08/01/designers-developers-and-the-x_-factor Good luck! Robby On Tue, Oct 21, 2008 at 10:32 AM, Nick <nick-qGbiljoI0DQkmLvzuZlaBw@public.gmane.org> wrote:> > 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 > > >-- Robby Russell Chief Evangelist, Partner PLANET ARGON, LLC design // development // hosting http://www.planetargon.com/ http://www.robbyonrails.com/ aim: planetargon +1 503 445 2457 +1 877 55 ARGON [toll free] +1 815 642 4068 [fax] --~--~---------~--~----~------------~-------~--~----~ 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 21, 1:48 pm, "Robby Russell" <ro...-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org> wrote:> When it comes to HTML... it''s kind of hard to not... hard-code it. > Either you end up having some dictionary that is a pain to manage or > you just have good conventions. > > This is what we do at Planet Argon to keep things a bit more organized. > > *http://www.robbyonrails.com/articles/2007/08/01/designers-developers-... > > Good luck! > > RobbyHi Robby. Thanks for the link and for sharing those conventions. The idea you guys decided upon definitely helps mitigate problems that involve renaming IDs. Hard-coding the DOM IDs still doesn''t sit right with me, though. It feels like the string-version of "magic" numbers, which was beaten out of me many, many years ago =P Thanks again, 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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
On Oct 21, 1:48 pm, "Robby Russell" <ro...-/Lcn8Y7Ot69QmPsQ1CNsNQ@public.gmane.org> wrote:> When it comes to HTML... it''s kind of hard to not... hard-code it. > Either you end up having some dictionary that is a pain to manage or > you just have good conventions. > > This is what we do at Planet Argon to keep things a bit more organized. > > *http://www.robbyonrails.com/articles/2007/08/01/designers-developers-... > > Good luck! > > RobbyBy the way, did you write a follow-up to the blog post above? I looked through your archives and a couple of tags, but didn''t find it. -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 rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---