适用于iOS的Phonegap / Cordova日历插件无响应

时间:2014-03-07 18:39:11

标签: javascript ios jquery-mobile cordova

我已将cordova插件添加到我的应用中。

命令行:

$ cordova plugin add https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin.git
$ cordova build

该插件似乎已正确添加,但当我将javascript添加到我的main.js时没有任何反应。 Main.js:

var startDate = new Date(2014,2,15,00,00,0,0,0); // beware: month 0 = january, 11 = december
var endDate = new Date(2014,2,15,00,00,0,0,0);
var place = "";
var notes ="";
var title = "";

function Calendar_Add(){

 var success = function() { alert("Success: " + JSON.stringify("Event Added!")); };
 var error = function(message) { alert("Error: " + "Something went wrong!"); };
 var location = place;

// create an event in a named calendar (iOS only for now)
window.plugins.calendar.createEvent(title,location,notes,startDate,endDate,calendarName,success,error);

}

的index.html:

<a href="#" onClick="Calendar_Add()" class="ui-btn ui-btn-inline">Add to Calendar</a>

3 个答案:

答案 0 :(得分:1)

添加deviceready事件。它应该工作。

   function Calendar_Add(){
     var startDate = new Date(2014,2,15,00,00,0,0,0); // beware: month 0 = january, 11 = december
    var endDate = new Date(2014,2,15,00,00,0,0,0);
     var place = "";
     var notes ="";
     var title = "";
     var success = function() { alert("Success: " + JSON.stringify("Event Added!")); };
     var error = function(message) { alert("Error: " + "Something went wrong!"); };
     var location = place;

    // create an event in a named calendar (iOS only for now)
    window.plugins.calendar.createEvent(title,location,notes,startDate,endDate,calendarName,success,error);
}

document.addEventListener("deviceready", Calendar_Add, false);

答案 1 :(得分:0)

createEvent不接受calendarName参数,如果您需要自己的日历,请使用calendarNameInNamedCalendar。

答案 2 :(得分:-1)

查看this,我确实在运行

我使用并且工作得非常好cal.createEventInteractively