在选择框中选择一个值时,我想使用特定参数触发刷新事件。
我在grails标签中定义了选择框:
<g:select name="resourceId"
from="${Resource.list()}"
optionKey="id"
optionValue="name"
onchange="refreshCalendar()"/>
我知道我可以使用标签中的onchange项目触发JS函数。
refreshCalendar函数:
$('#calendar').fullCalendar('refetchEvents')
我的日历配置为:
$('#calendar').fullCalendar({
events: '${createLink(action:'loadSchedule' )}'
}
现在如何在全日历配置中提供日历刷新功能或事件项,并在选择框中选择一个id参数?
谢谢
最佳答案
不知道这是否是“很酷”的方法,但是现在可以通过以下解决方案使用:
var source;
function refreshCalendar(id) {
source = '${createLink(action:'loadSchedule' )}' + '?resourceId=' + id;
$('#calendar').fullCalendar('removeEvents');
$('#calendar').fullCalendar('addEventSource', source );
$('#calendar').fullCalendar('rerenderEvents');
$('#calendar').fullCalendar('removeEventSource', source );
}
因此,日历将使用新的src加载,之后将其删除
关于javascript - 在选择时使用参数触发完整日历刷新,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7759898/