Fullcalendar日doubleclick回调 [英] Fullcalendar day doubleclick callback
问题描述
我需要在dblclick上工作的实现函数,如dayClick回调函数。我尝试了所有我找到的解决方案,但没有为我工作,例如米歇尔的回答。顺便说一下,所有的线程都很旧。
这个问题看起来很琐碎,但我没有意识到为什么它不起作用。
有谁知道这应该在最新版本中完成吗?
b$ b
好吧,我发现了这个问题:)
在我设置这个选项时停止工作: selectable:true
我补充一点:
dayRender:(date,element,view) - >
element.binddblclick, - >
提醒双击!
dayClick:(date,jsEvent,view) - >
$(。fc-highlight)。removeClass(fc-highlight)
$(jsEvent.toElement).addClass(fc-highlight)
$ c $
感谢您的帮助。
$ / pre
b
$ b
UPDATE 2
然而,上述解决方案并不完美。一些元素覆盖了日期对象,并且它无法在整个表面上工作,所以我想出了另一种解决方案:
findClickedDay =(e) - >
days = $(#calendar .fc-day)
i = 0
while I< days.length
day = $(days [i])
mouseX = e.pageX
mouseY = e.pageY
offset = day.offset()
width = day.width()
height = day.height()
if mouseX> offset.left和mouseX< offset.left + width和mouseY> offset.top和mouseY< offset.top +高度
返回日
i ++
eventAfterAllRender:(view)=>
$(#calendar)。binddblclick,(e)=>
clickedDay = findClickedDay(e);
clickedDay.length == 0然后返回
date = new Date(clickedDay.data('date'))
alertdblclick on date:#{date}
解决方案 它可以很好地与 eventRender
Click for jsfiddle link。
eventRender
当一个事件被渲染时触发。 &安培;&安培; dayRender
是用于修改星期几单元的挂钩。 Click for dayRender docs
eventRender:function(event,element){
element.bind('dblclick',function(){
alert('double click!');
});
},
I need implement function working on dblclick, like dayClick callback. I tried all solutions, which I found, but nothing work for me, eg Michel's answer. By the way, all threads are quite old.
The problem seems so trivial, but I ran out of ideas why it doesn't work.
Does anyone know how this should be done in the latest version?
UPDATE
ok, I found the problem :)
it stops working when I set this option: selectable: true
I add this instead:
dayRender: (date, element, view) ->
element.bind "dblclick", ->
alert "double click!"
dayClick: (date, jsEvent, view) ->
$(".fc-highlight").removeClass("fc-highlight")
$(jsEvent.toElement).addClass("fc-highlight")
And works perfectly :)
Thanks for Your help.
UPDATE 2
However, the above solution is not perfect. Some elements cover day object and it doesn't work on entire surface of day, so I came up with another solution:
findClickedDay = (e) ->
days = $("#calendar .fc-day")
i = 0
while i < days.length
day = $(days[i])
mouseX = e.pageX
mouseY = e.pageY
offset = day.offset()
width = day.width()
height = day.height()
if mouseX > offset.left and mouseX < offset.left + width and mouseY > offset.top and mouseY < offset.top + height
return day
i++
eventAfterAllRender: (view) =>
$("#calendar").bind "dblclick", (e) =>
clickedDay = findClickedDay(e);
if clickedDay.length == 0 then return
date = new Date(clickedDay.data('date'))
alert "dblclick on date: #{date}"
解决方案 It works fine with eventRender
Click for jsfiddle link.
The eventRender
Triggered while an event is being rendered. && dayRender
is A hook for modifying a day cell. Click for dayRender docs
eventRender: function(event, element) {
element.bind('dblclick', function() {
alert('double click!');
});
},
这篇关于Fullcalendar日doubleclick回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文