Reputation: 682
I am on cordova and trying to create Events in native Calander of Phone. Here is my Code. I added below code in Config.xml
<gap:plugin name="nl.x-services.plugins.calendar" version="4.2" />
and my function as below:-
function CreateEvent()
{
alert("Start")
var startDate = new Date(2014, 4, 31, 18, 30, 0, 0, 0); // beware: month 0 = january, 11 = december
var endDate = new Date(2014, 4, 31, 19, 30, 0, 0, 0);
var title = "Skype meeting With Lead";
//var location = "myleads.html";
var notes = "Need to do a skype meeting with the lead.";
var success = function (message) { alert("Success: " + JSON.stringify(message)); };
var error = function (message) { alert("Error: " + message); };
// window.plugins.calendar.listEventsInRange(startDate,endDate,success,error);
// window.plugins.calendar.createCalendar(calendarName,success,error);
window.plugins.calendar.createEvent(title, location, notes, startDate, endDate, success, error);
alert("End")
alert("Sucess",success)
}
$(document).ready(function () {
$("#btnClick").bind("click", CreateEvent,false);
});
but it is giving Error on click i.e window.plugin
is undefined.
Upvotes: 0
Views: 2085
Reputation: 624
What are you testing your code on?
Are you emulating an android/ios device? Debugging on your phone? Running it as localhost?
If you're not running it on a mobile device you won't have access to these plugins and their native dependencies.
For testing purposes you'll have to check whether the plugin has been loaded.
if (window.plugins && window.plugins.calendar) {
window.plugins.calendar.createEvent(title, location, notes, startDate, endDate, success, error);
}
A list of other things you can try:
Upvotes: 3