Ale*_*hew 1 jquery fullcalendar
嗨朋友
我正在使用完整的日历应用程序,在那个,我点击一个事件,它必须重定向到另一个页面,并发布数据,如事件ID,事件开始,事件结束,用户ID等,我怎么能在J Query和Full Calender中执行此操作
我想你可以这样做:
$('#calendar').fullCalendar({
eventClick: function(calEvent, jsEvent, view) {
window.location = 'page.php?'
+ 'id=' + calEvent.id
+ '&start=' + calEvent.start
+ '&end=' + calEvent.end
+ '&user_id=' + calEvent.user_id;
}
});
Run Code Online (Sandbox Code Playgroud)
您可以使用此方法来发布数据:
function post_to_url(path, params, method) {
method = method || "post"; // Set method to post by default, if not specified.
// The rest of this code assumes you are not using a library.
// It can be made less wordy if you use one.
var form = document.createElement("form");
form.setAttribute("method", method);
form.setAttribute("action", path);
for(var key in params) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
document.body.appendChild(form); // Not entirely sure if this is necessary
form.submit();
}
Run Code Online (Sandbox Code Playgroud)
从这里拿走它.
如何使用它的一个例子:
$('#calendar').fullCalendar({
eventClick: function(calEvent, jsEvent, view) {
var method = 'POST';
var path = 'page.php';
var params = new Array();
params['event_id'] = calEvent.id;
params['event_start'] = calEvent.start;
params['event_end'] = calEvent.end;
params['event_user_id'] = calEvent.user_id;
post_to_url(path, params, method);
}
});
Run Code Online (Sandbox Code Playgroud)