On May 29, 8:53 am, Martin Wawrusch <mar...@wawrusch.com> wrote:
> Depending on the kind of site you might want to use mvc views through
> backbone or something similar and launch specific views depending on the
> current page, something like so:
>
> html:
> body class=´users search_page´
> ...
>
> and in your coffeescripts (you do use coffeescript :P)
>
> class UserSearchView extends Backbone.View # or controller
>    ...
>   initialize: ->
>     here goes your page specific initializers
>
> $ ->
>   window.currentView = new UserSearchView if $(´body.users.search').length >
> 0
>
> I have never been a huge fan of libs like require.js except for real big web
> apps, mostly it is better to just dump the whole javascript in one minified
> file.

My project is probably going to turn out to be one big web app ;)

I can work with whatever design Rails wants me to go with... I just
want to make sure what that is.

So if I were to use backbone (I probably will), what is top those
backbone objects from getting instantiated on pages where they aren't
needed?

With require.js, I was able to put 1 script_include_tag at the bottom
of the page that loaded a javascript file which ignited the rest of
the javascript code for that page. It was like a controller, but for
javascript basically. This ensured that this controller code would
only be executed on this page - and no other.

Now I am at a loss as to how to achieve this without using page-
specific pages. I guess I don't need Javascript anymore, but I'm
thinking I will still have to remove this line:

//= require_tree .

Correct?

-- 
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.

Reply via email to