0

I'm using the jQuery FullCalendar plugin with Ruby on Rails, and now I want to show the event details in a jquery dialog when you click on an event in the calendar. I have this in my controller EventsController

  # GET /events/1
  # GET /events/1.xml
  def show
    @event = Event.find(params[:id])

    respond_to do |format|
      format.html # show.html.erb
      format.xml  { render :xml => @event }
      format.js { render :json => @event.to_json }
    end
  end

which works as intended if I visit the url /events/1 for example. Then I see the form generated in app/views/events/show.html.erb. However, in my calendar.js where I'm trying to GET that form and insert it into my dialog div with this code:

    // http://arshaw.com/fullcalendar/docs/mouse/eventClick/
    eventClick: function(event, jsEvent, view){
      $.get('/events/' + event.id, function(data, text, jqXhr) {
          eventdialog.html(data);
          eventdialog.dialog("open");
      });
    },

'data' only contains the JSON-data. Sorry if this is a nooby question, but i've tried googling for hours now but I can't seem to find what i'm looking for. Using RoR 3.2.2.

1

1 Answer 1

1

Last line should be like format.js { render :partial => 'event' }

Sign up to request clarification or add additional context in comments.

2 Comments

Thanks for the answer, it didn't work though. I got this error from the server: ActionView::MissingTemplate (Missing partial events/event, application/event with {:handlers=>[:erb, :coffee, :builder], :formats=>[:js, :html], :locale=>[:en]}. Searched in: * "/home/cakism/railscode/calendar/app/views" ): app/controllers/events_controller.rb:29:in show' app/controllers/events_controller.rb:26:in show'
This is a example. Error says you should implement '_event.html.erb' file. I thought you already have this file. Try {render :template => 'show'} or {render :template => 'show', :layout => false} in this case, only html from 'show.html.erb' will be sent.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.