Here is the very condensed form how I am doing it:

Each rendered view contains a class "controller_nameofcontroller" and
"controllername_actionname" attached to the body element

In my scripts I have the following scenarios ( I am using backbone, but this
works as well without it):

1. Applies to everything: Generic startup and configuration, for example for
colorbox. I run a

class AppView extends Backbone.View
el: $('#outercontainer')
 initialize: ->
$('.token_input_cont').each (i,x) ->
$(x).tokenInput  $(x).data("source"),
 preventDuplicates : true
prePopulate: $(x).data("pre")
theme: $(x).data("theme") || ''
$ ->
window.App = new AppView

and make sure that the init code retrieves it's processing instructions from
the tags as shown in the above example. This way
you can control a lot of functionality through markup.

2. To have functionality targeted at specific pages I use this:

$ ->
window.HomeIndexView = new HomeIndexView if $('body.home_index').length > 0

where I check for the existence of the tag.

Hope this helps a bit


On Thu, Jun 9, 2011 at 9:08 AM, Alex Katebi <[email protected]> wrote:

>
>   Are there any examples on how to use coffee script in your rails app. I
> don't know how people are using coffee script. I know the mechanics of how
> to write the coffee script. But how do I tie it to my views / application?
>
>
>
>
>
> --
> 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.
>

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