I guess I am going to blog about this once I have a bit more time. In general my observation with websites and javascript is that you have lots of code that applies to all pages if you structure it right (usage of class names in css), and very few pages that have intense, page specific code. The project I am working right now has about 1000 lines of coffeescript for the search page and maybe 200 for the rest of the site (and some custom jquery plugins), which makes solutions like the one I proposed rather save. The class is attached to the body because I am following the *html5* boilerplate.com/ conventions.
On Sun, May 29, 2011 at 6:18 AM, egervari <ken.egerv...@gmail.com> wrote: > >class UserSearchView extends Backbone.View # or controller > > ... > > initialize: -> > > here goes your page specific initializers > > > >$ -> > > window.currentView = new UserSearchView if $(´body.users.search').length > > > >0 > > This solution looks interesting, and it also looks potentially > dangerous. I'm not a fan of string-based rules like this. I guess I > can just get used to it (and of course not rely on the body, but > perhaps a <div id="user_search"> or something like that. > > I will play with it. It might be nice to never have to care to include > the script tag at the bottom of page, using require or not. > > -- > 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@googlegroups.com. > To unsubscribe from this group, send email to > rubyonrails-talk+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- 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@googlegroups.com. To unsubscribe from this group, send email to rubyonrails-talk+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.