Full Calendar

22 views
Skip to first unread message

Scott LaBounty

unread,
Sep 14, 2009, 6:42:46 PM9/14/09
to ram...@googlegroups.com
Has anyone used FullCalendar(http://arshaw.com/fullcalendar/) with Ramaze? I'm can't get it to show the events I'm passing back (AJAX) from my controller. I'm definitely getting the request. Here's the controller code:

    def show_calendar
        @page_javascript = 'show_calendar'
        if request.xhr? # came from ajax request
            # Create a JSON "object" of the choice that can in through the post
            # request and the current time. For the time, we need to enclose it
            # in double quotes so that it will be interpreted as a string.
            # "{ choice: #{request['choice']}, time: \"#{Time.now}\" }"
           
            Ramaze::Log.debug("show_calendar: Have an Ajax request start: #{request['start']} end: #{request['end']}")
            # "{ id: 1, title: \"Event1\", start: \"2009-09-15\" }"
            Ramaze::Log.debug("#{JSON.pretty_generate([{"id"=>1, "title" => "Event1", "start" => "2009-09-15"}])}")
            json = JSON.generate [{"id"=>1, "title" => "Event1", "start" => "2009-09-15"}]
            return json
        end

    end


You can see I've tried a couple of different ways of passing (straight string and then using the JSON plugin).

Any ideas?
--
Scott
http://steamcode.blogspot.com/

kez

unread,
Sep 15, 2009, 2:45:06 AM9/15/09
to Ramaze
I've been trying to do something like this with DatePicker...had no
idea this was out there.

Hopefully can try and implement it today, so will let you know if I
get events working.

kez.

hrnt

unread,
Sep 15, 2009, 5:11:27 AM9/15/09
to Ramaze
Instead of "return json", try "respond(json, 200)".
If you just return the string, it will be wrapped in your layout, or
completely ignored
if you have a view for that action.

(I am not sure if it is necessary to use that second parameter with
respond, but I don't have
Ramaze docs open at the moment)

Nick Robinson-Wall

unread,
Sep 15, 2009, 6:35:26 AM9/15/09
to ram...@googlegroups.com
2009/9/15 hrnt <aot...@gmail.com>:

> (I am not sure if it is necessary to use that second parameter with
> respond, but I don't have
> Ramaze docs open at the moment)

Nope, that's optional. I didn't even realise there was a second
parameter for respond, you learn something new every day.

Scott LaBounty

unread,
Sep 15, 2009, 10:17:03 AM9/15/09
to ram...@googlegroups.com
I'll give this a try today, but I do have the line:

    layout(:page){ !request.xhr? }

that should make it so that it doesn't use the layout for this. The respond does make it more clear though, what's going on, so I'll give it a shot.

Thanks for the help.
--
Scott
http://steamcode.blogspot.com/

Scott LaBounty

unread,
Sep 15, 2009, 12:21:26 PM9/15/09
to ram...@googlegroups.com
OK, I admit to being skeptical but ... the respond worked but ... it did have to have the 2nd parameter of 200 so what I ended up with was

respond(json, 200)

I'm not sure why or how, but that did it.

Thanks everyone!

--
Scott
http://steamcode.blogspot.com/

Greg Saunderson

unread,
Sep 15, 2009, 1:28:59 AM9/15/09
to ram...@googlegroups.com
Hi Scott,

generally when troubleshooting AJAX issues, I rely on the Net tab in
Firebug to show me the output of the requested page.

I find any extraneous output on that page (error messages, warnings)
will break the AJAX call and the function handling the response will
not know what to do with the mangled response.

Not sure if that's at all useful to you.

Cheers,

Greg

Scott LaBounty

unread,
Sep 15, 2009, 12:58:10 PM9/15/09
to ram...@googlegroups.com
Greg,

I hadn't seen that before and yes, I can see where that would be really useful. I'm going to try with my not working version just to see what I get there.

Thanks!

Scott
--
Scott
http://steamcode.blogspot.com/
Reply all
Reply to author
Forward
0 new messages