0

I am trying to integrate the arshaw's jQuery fullcalendar into my rails application. When I click on the calendar tab it should display the calendar with the list of tasks in the database on the corresponding date.

In calendar controller

    def index

    @task=Task.find_all_by_pm_id(params[:u])
      @task.each do |t|
        @task_name=t.task_name
        @end_date=t.due_date
      end
    end

In the Calenders/index.html.erb

    <script>
     $(document).ready(function() {
        var date = new Date();
        var d = <%=@end_date.day%>;
        var m = <%=@end_date.month%>-1;
        var y = <%=@end_date.year%>;
        var calendar = $('#calender').fullCalendar({
            header: {
                left: 'prev,next today',
                center: 'title',
                right: 'month,agendaWeek,agendaDay'
            },
            selectable: true,
            selectHelper: true,
            events: [
                {
                    title: '<%=@task_name%>',
                    start: new Date(y, m, d)
                },

            ],
            editable: true

        });

    });

</script>

Now it is displaying only the last task name. I need to display all the task name on particular dates. Any inputs on this will be appreciated. Please help

4

1 回答 1

0
events: [
{
title: '<%=@task_name%>',
start: new Date(y, m, d)
}
],

should contain an array of events, in your code you are filling it with the only one with the @task_name, try to change in something like events : <%=task%> but check the input respects the JSON array format

于 2012-09-26T13:17:09.077 回答