I have something like this in my Project#show view:
...
<p>
<b>Start date:</b>
<%= @project.start_date %>
</p>
<p>
<b>End date:</b>
<%= @project.end_date %>
</p>
<div id="calendar_view">
</div>
And I have the following in my projects.js.coffee:
$ ->
$("#calendar_view").datepicker({
inline: true
})
The thing is, I would like to instantiate the datepicker with some relevant information ( such as the span of the project in months, restrict it to the beginning and end of the project ). Is there a way to mix some ruby, or the actual project’s data inside the coffeescript?
For my projects, I typically add an additional
yieldblock to the end of our documents, right before the closing body tag.This way, in views, I can append less obtrusive JavaScript to the end of the document via a
content_for :additional_javascriptblock: