我有類似的this完整的日曆,你可以看到你可以創建事件寫入輸入並點擊按鈕。獲取選定的值來添加事件fullCalendar
而不是我有一個選擇我想創建具有選定值的事件,有沒有posible?
HTML:
<select id="lstRegion" class="form-control select2 select2-accessible agenda_space" aria-hidden="true"></select>
<a href="javascript:;" id="event_add" class="btn green"> Add Event </a> </div>
<div id="event_box" class="margin-bottom-10"></div>
JS:
//load region dropdown
$("#lstRegion")
.getJSONCatalog({
onSuccess: function (response) {
console.log(response);
},
url: '/Agenda/GetRegion',
valueProperty: "ID",
textProperty: "valor"
});
//Event logic
var initDrag = function (el) {
// create an Event Object (http://arshaw.com/fullcalendar/docs/event_data/Event_Object/)
// it doesn't need to have a start or end
var eventObject = {
title: $.trim(el.text()) // use the element's text as the event title
};
// store the Event Object in the DOM element so we can get to it later
el.data('eventObject', eventObject);
// make the event draggable using jQuery UI
el.draggable({
zIndex: 999,
revert: true, // will cause the event to go back to its
revertDuration: 0 // original position after the drag
});
};
var addEvent = function (title) {
title = title.length === 0 ? "Untitled Event" : title;
var html = $('<div class="external-event label label-default">' + title + '</div>');
jQuery('#event_box').append(html);
initDrag(html);
};
$('#external-events div.external-event').each(function() {
initDrag($(this));
});
$('#event_add').unbind('click').click(function() {
var title = $('#event_title').val();
addEvent(title);
});
因此,不是用戶輸入的文本,而是想要選擇事件的下拉菜單? *我想創建具有選定值的事件,有沒有可能?*是的,這是可能的。 – Twisty
是的,我的下拉菜單中有值,所以我想通過文本選擇值。我怎麼能這樣做@Twisty – Gerardo