coffeescript中的方法内部参数

时间:2012-10-18 12:29:18

标签: coffeescript

有人可以告诉我coffeescript不会将该方法作为另一个参数处理吗?

$('#id-calendar').fullCalendar
  aspectRatio: 0.5
  editable: true
  droppable: true
  defaultView: 'agendaWeek'
  slotMinutes: 120
  minTime: 8
  maxTime: 20
  firstDay: startDate()
  drop = (date, allDay, jsEvent, ui) ->
    console.log(date)
    console.log(allDay)
    console.log(jsEvent)
    console.log(ui)
    originalEventObject = $(this).data('eventObject')
    copiedEventObject = $.extend({}, originalEventObject)
    copiedEventObject.start = date
    copiedEventObject.allDay = allDay
    $('#id-calendar').fullCalendar('renderEvent', copiedEventObject, true)
    $(this).remove()
    return true 

输出结果为:


var drop;

$(document).ready(function() {
  var startDate;
  startDate = function() {
    var day, today;
    today = new Date();
    day = today.getDay();
    switch (day - 2) {
      case -1:
        return 6;
      case -2:
        return 5;
      default:
        return day - 2;
    }
  };
  return $('#external-events div.external-event').each(function() {
    var eventObject;
    eventObject = {
      title: $.trim($(this).text())
    };
    $(this).data('eventObject', eventObject);
    return $(this).draggable({
      zIndex: 999,
      evert: true,
      revertDuration: 0
    });
  });
});

$('#id-calendar').fullCalendar({
  aspectRatio: 0.5,
  editable: true,
  droppable: true,
  defaultView: 'agendaWeek',
  slotMinutes: 120,
  minTime: 8,
  maxTime: 20,
  firstDay: startDate()
}, drop = function(date, allDay, jsEvent, ui) { === BUG
  var copiedEventObject, originalEventObject;
  console.log(date);
  console.log(allDay);
  console.log(jsEvent);
  console.log(ui);
  originalEventObject = $(this).data('eventObject');
  copiedEventObject = $.extend({}, originalEventObject);
  copiedEventObject.start = date;
  copiedEventObject.allDay = allDay;
  $('#id-calendar').fullCalendar('renderEvent', copiedEventObject, true);
  $(this).remove();
  return true;
});

1 个答案:

答案 0 :(得分:3)

应该是

drop: (date, allDay, jsEvent, ui) ->

而不是drop =