Packing a json object

hi,

i am using http://arshaw.com/fullcalendar/ to display a calendar.

It uses json to populate the calendar events.

The JSON looks like this
events: [
{
title: ‘All Day Event’,
start: new Date(y, m, 1)
},
{
title: ‘Long Event’,
start: new Date(y, m, d-5),
end: new Date(y, m, d-2)
},
{
id: 999,
title: ‘Repeating Event’,
start: new Date(y, m, d-3, 16, 0),
allDay: false
}
]

A date looks like Fri Jul 29 2011 22:54:08 GMT-0400 (EDT)

When i select from my events table i run:
@member_calendars = Member::Calendar.find_by_sql(“SELECT * from
calendars”)
@json_calendar = ActiveSupport::JSON.encode(@member_calendars)

How can i get my dates into a format that works for this json object?

Also, how would i pull my json object into the view so i can play with
it in javascript.

The following code treats my json object as a string:

          var foo = '<%= @json_calendar %>';
            $.each(foo, function(i, item) {
                    alert(i);
            });

It will alert each and every character from my object

On Jul 30, 3:57am, jdkealy [email protected] wrote:

A date looks like Fri Jul 29 2011 22:54:08 GMT-0400 (EDT)

When i select from my events table i run:
@member_calendars = Member::Calendar.find_by_sql(“SELECT * from
calendars”)
@json_calendar = ActiveSupport::JSON.encode(@member_calendars)

How can i get my dates into a format that works for this json object?

Looks like that calendar plugin would be happy with iso8601 dates,
which is what rails should generate by default when encoding dates as
json

Also, how would i pull my json object into the view so i can play with
it in javascript.

The following code treats my json object as a string:

   var foo = '<%= @json_calendar %>';

You asked for it to be a string - you’ve enclosed it in quotes

Fred

when i try this without quotes, all my javascript breaks.

On Jul 30, 10:47am, Frederick C. [email protected]

On Jul 30, 4:17pm, jdkealy [email protected] wrote:

when i try this without quotes, all my javascript breaks.

probably worth looking at what’s wrong then.

Fred