Hi is there a way to change the time format for the following snipp in fullcalendar?
select: function(startDate, endDate) {
$.fancybox({
\'width\': \'40%\',
\'height\': \'40%\',
\'autoScale\': true,
\'transitionIn\': \'fade\',
\'transitionOut\': \'fade\',
\'type\': \'iframe\',
\'href\': \'test.php/?start=\'+startDate+\'&end=\'+endDate,
});
calendar.fullCalendar(\'unselect\');
}
I want Start & EndDate to be a unix Timestamp.
Thank You
It can be achieved by overriding the "start" and "end" parameter by sending separating Ajax Request inside the FullCalendar.
Take a look at this Similar Thread: add custom params to fullcalendar request
Related
I'm creating an event data via GTM, and typically if it's sent to GA the timezone will follow the GA timezone but if I sent it to a different endpoint how do I capture the timestamp for the GTM event? Would I have to populate it in the dataLayer?
You may create a custom variable using javascript. That custom variable will return the current timestamp (beware that you may need to deal with browsers timezones, if that is important to you).
Go to Variables and add a new using the type Custom JavaScript:
Then the code could be along this lines (grabbed from here), depending on the format you want to return:
function() {
try {
var timestamp = new Date();
var time = timestamp.toString().split(' ');
return time[3]+ " " +time[1]+ " " +time[2]+ " "+time[4];
} catch(e) {
return "unknown";
}
}
After that, a variable with the name given (in this case I used 'Timestamp') will become available as {{Timestamp}} You then can plug it in the event or whatever tag you are creating. You may even use it as {{Timestamp}} inside a Javascript tag. The variable will return a timestamp in the format: 2020 May 30 11:41:44
i am new developer and i want to make an app in cakephp 3.7 thas uses jquery full calendar plugin for reservations.In my database is stored a specific date range (starting date and ending date fields).I want to use this date range in my calendar so that if a user clicks on a specific day on the callendar that is out of this date range, the app will display a messange informing the user that he cannot make a reservation for that day!
Any useful suggestions on who i will handle on this ??
Thank you!!
I have done it using the cakephp 3.6.
Generic steps that you would follow:
You will include your full calendar js and jquery in the 'full
calendar' template
Then initialise your fullcalendar. Now you should see the calendar.
Once done, from the fullcalendar make an ajax call to your controller to get the events. eg.
var fcSources = {
loadEvents: {
url: //your controller action,
type: "GET",
cache: true,
timezone: "Europe/London",
className: "events",
dataType: "json",
success: function (data) {
return data.events;
}
},
}
Later part can be done by simply checking the date value against current date.
Is there a way to filter events based on a drop down?
I tried :
events: '/Controller/action?id='+id,
$("#drop").change(function () {
id = $('#drop').val();
$('#calendar').fullCalendar('refetchEvents');
But the controller does not see the new id.
Any suggestions on passing a paremter to the events() method?
You gave the result of '/Controller/action?id='+id to the calendar as the events feed when the calendar was initialised. e.g. you passed in /Controller/action?id=3, for example. That code has run and does not run again. fullCalendar stores that static string as the URL of the events feed. It doesn't pay any attention to the value of "id" later.
The simplest way to solve this is probably using a custom event feed, as per https://fullcalendar.io/docs/event_data/events_function/ :
//declare the calendar with a custom "events" functions
$("#calendar").calendar({
//..all your calendar options, and then the events:
events: function( start, end, timezone, callback ) {
$.ajax({
//whatever ajax parameters you need, but make sure:
url: /Controller/action,
data: { "id": $('#drop').val(), "start": start.format("YYYY-MM-DD"), "end": end.format("YYYY-MM-DD") }
});
}
});
$("#drop").change(function () {
$('#calendar').fullCalendar('refetchEvents');
});
That way, when "refetchEvents" is called, it runs the function that you passed as the "events" parameter, which can look up the value of the dropdown dynamically at that moment in time.
Note I've also added "start" and "end" parameters to your data, because your event source is supposed to filter the events returned by the dates actually being displayed on the calendar, otherwise you end up returning all events every time the view or date changes.
In Scheduler Calendar, Iam getting the resources from resources.json on the first column.
Iam trying to add the events for each resources.
When I click the slotduration straight to each resources, I should get the resourceId. So, I would know to which resources, Iam adding the events.
In select function, Iam able to get only the start and end time, but NOT the resourceId.
Any help will be highly appreciated.
There is fourth argument in the select callback, Using that you would be able to get resource. see the example below.
$('#calendar').fullCalendar({
select: function (start, end, calendar,res)
{
//to get resource
console.log(res);
}
});
It will give you json object.
To get resource id on click of resource header do the following changes in scheduler.js,
modify below method.add id and class to the resource header.
ResourceRow.prototype.renderSpreadsheetContent = function(tr) {
.......
.......
td = $('<td id="'+resource.id+'" class="' + this.view.widgetContentClass + ' resourceHeader"/>').append(contentEl); // add id and class to the resource header.
.......
.......
}
After changing the code just bind an event in your js file as below
$(".resourceHeader").click(function(){
var resourceId=$(this).attr("id");
//write a code to get all the events of selected resource
//and render it on calendar
});
You are good to go now.
Thanks
I am new to TinCan, I am building a course where I need to set the completion status to completed and also the time needs to be recorded. I am using an LMS and also scormcloud for testing.
Currently, the completed status is working but it's not capturing the time spent.
This is the code:
var tincan = new TinCan({url: location.href});
tincan.sendStatement(new TinCan.Statement({
verb: 'completed',
result: {
success: true
}
}));
To include duration in that statement you should use the result.duration property. This is an ISO 8601 duration representing the attempt duration (rather than session duration). I actually have a blog on duration due out in the next month or so that I hope you'll find helpful.
I'd also recommend using a full verb object and using result.completion instead of result.success for a completion statement.
So your final code will be:
var tincan = new TinCan({url: location.href});
tincan.sendStatement(new TinCan.Statement({
verb: {
id: "http://adlnet.gov/expapi/verbs/completed",
display:{
"en-US": "completed"
}
},
result: {
completion: true,
duration: "PT21.896S"
}
}));
Note also that it be may best not to rely on the activity definition from the query string, but I appreciate you may be keeping the code sample short for the sake of the question.