最近我需要在垂直方向上在fullcalendar.js中渲染事件。
我的解决方案类似于谁需要它,不介意使用" gambiarra":
eventRender: function(event, element) {
element[0].setAttribute("dia",event.data);
element[0].setAttribute("hora",event.hora);
},eventAfterAllRender: function(event, element)
{ organizacalendario() },
eventAfterRender: function(event, element)
{
var existe = 0;
$(arrayorder).each(function(index,value)
{
if ( event.hora == value)
{
existe = 1;
return;
}
});
if ( existe == 0 )
{
arrayorder.push(event.hora);
}
arrayorder.sort(); }
function organizacalendario()
{
$(arrayorder).each(function(index,horaelemento)
{
//renderiza os elementos da hora definida
$("#calendar").find(".fc-time-grid-event").each(function(ordem,element)
{
$(element).css("left","");
$(element).css("right","");
$(element).css("bottom","");
if ( $(element).attr("hora") == horaelemento && $(element).css("z-index") > 1 )
{
if ( horaelemento.substring(3,5) <= 29 && $(element).attr("data") == $(previous).attr("data") )
{
// aumenta o fc-axis para suportar + 1 evento
$(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr").css("height", Number($(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr").css("height").replace("px","")) + Number($(element).css("height").replace("px","")));
}else if ( horaelemento.substring(3,5) >= 30 && $(element).attr("data") == $(previous).attr("data") )
{
// aumenta o fc-axis para suportar + 1 evento
$(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr").next("tr").css("height", Number($(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr").next("tr").css("height").replace("px","")) + Number($(element).css("height").replace("px","")));
}
//seta top de acordo com height anteriro
$(element).css("top",Number($(previous).css("top").replace("px","")) + Number($(previous).css("height").replace("px","")))
}
else if ( $(element).attr("hora") == horaelemento )
{
if ( horaelemento.substring(3,5) <= 29 )
{
$(this).css("top",$(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr")[0].offsetTop)
}else
{
$(this).css("top",$(".fc-slats").find("span:contains('"+horaelemento.substring(0,2)+"')").parent("td").parent("tr").next("tr")[0].offsetTop)
}
}
$(".fc-time-grid-container").css("height",$(".fc-slats").css("height"));
$("#area_container").css("background","");
previous = this;
})
})
}
但是,问题是..有人在fullcalendar.js中发生了一些变化,以便在没有&#34; gambiarras&#34;?的情况下发生变化。我尝试在eventafterrender中完成所有操作但看起来像fullcalendar渲染器通过不同的参数排序,然后json字符串。如果有人能给我看一个最优雅的解决方案,我会很高兴正面...谢谢