DatePicker plugin not working in PhoneGap 1.5

I am trying to use the PhoneGap DatePicker plugin (PhoneGap 1.5 (Cordova) in Xcode 4.2) for iOS. I have added DatePicker.h and DatePicker.m files to the Plugins folder and DatePicker.js to the www folder. Also, I edited the Cordova.plist file to add a new entry for the DatePicker plugin with "DatePicker" as key and "DatePicker" as value. I am using the following code to show the DatePicker

var cb = function(date) {
    console.log(date.toString());
    document.getElementById("date").innerHTML = date.toString();
}

var show = function(mode) {
    plugins.datePicker.show({
        date: new Date(),
        mode: mode, //date or time or blank for both
        allowOldDates: false
        }, cb);
}

      

but it doesn't work. Any suggestions?

+3


source to share


1 answer


While on the phone, I used the following approach to determine why the plugin was not working:

I use Weinre for this . Start the weinre server, enable weinre javascript on your page, and deploy the app to a device that is on the same (wireless) network or running on an iOS simulator. (Do not forget to include the IP address of the weinre server under the ExternalHosts key in the file used for the Phonegap.plist name)

Now that the application is running, you can go to the debug console and check the value of window.plugins. You can do this by simply typing window.plugins

in the console. If you do not see a list of plug-ins, you need to check whether the added files correctly .m

and .h

in the project. It's easy to go wrong in Xcode and accidentally include them by reference.



If the plugin is available, you can directly attempt to invoke it using the Weinre remote debug console. You should also get good feedback in case of any mistakes.

At this point, you usually nail the error. If the datepicker is available for phone calls, but it does not work correctly, you can now set breakpoints in the file .m

and run the application in debug mode on the iOS simulator from Xcode. Now walk through the plugin to see why the native iOS code isn't working.

0


source







All Articles