2016-11-15 4 views
0

FullCalendarの月表示でイベントを1日にレンダリングする際に問題が発生しています。以下は、カミソリページの.getJSON呼び出しです。続いてコントローラJsonResultとオブジェクトがWebコンソールに表示されます。コントローラアクションから.getJSON()を使用したFullCalendarレンダリングイベントの問題

例ごとのハードコーディングは完全に機能しますが、_calendarInit()に_calendarEventsとして実際に渡されるものをデバッグするのには苦労しています。私に

var _calendarEvents = []; 
    $.getJSON('/Timesheets/GetAll', function (data) { 
     var _calendarEvents = data; 
    }) 

public JsonResult GetAll() 
    { 

     var timesheet = _context.Timesheet 
      .Include(t => t.Program) 
      .Include(t => t.Task) 
      .Select(t => new 
      { 
       id = t.Id.ToString(), 
       title = t.Name, 
       start = t.TaskStart, 
       end = t.TaskEnd, 
       className = "['bg-primary']", 
       description = t.Description, 
       icon = "fa-clock-o", 
       program = t.Program.Name, 
       task = t.Task.Name, 
       allDay = t.AllDay 
      }).ToList(); 

     return Json(timesheet); 
    } 

enter image description here

、データがOKになります。私はそれが非同期のgetJSON()の問題であるかどうかは、レンダリングイベントのinscopeまたはそれらの行に沿ったものではないことを意味しているのだろうかと思います。

ありがとうございます。

答えて

0

物事の論理的な順序を理解することは私の問題でした。下の回答は、ここでの回答のおかげです。LogicalOrderとここにReturning Response of Async Call

/*GET*/ 
    function getEvents(callback) { 
     $.getJSON('/Timesheets/GetAll', callback); 
    } 

    var _calendarEvents = []; 
    getEvents(function (json) { 
     _calendarEvents = json; 
     // your logic here 
    }); 
関連する問題