Skip to content Skip to sidebar Skip to footer

"backbutton" Event Won't Fire

I am attempting to build a phonegap app for Windows Phone 7. I am trying to follow the documentation for the 'backbutton' event (http://docs.phonegap.com/en/2.0.0/cordova_events_ev

Solution 1:

I managed to fix this by copying some parts of cordova-1.8.1.js to cordova-2.0.0.js.

In 1.8.1, search for: var NamedArgs and copy the whole object to 2.0.0.

In 2.0.0, search for: var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args); and replace it with:

if ( action == 'overridebackbutton' ) {
    if ( NamedArgs[service] && NamedArgs[service][action]) {
        var argNames = NamedArgs[service][action];
        var newArgs = {};
        varlen = Math.min(args.length,argNames.length);

        for(var n = 0; n < len; n++) {
            newArgs[argNames[n]] = args[n];
        }

        args = newArgs;
    }
    elseif(args && args.length && args.length == 1) {
        args = args[0];
    }
}
var command = service + "/" + action + "/" + callbackId + "/" + JSON.stringify(args);

This might not be a pretty solution, but it works for me.

Solution 2:

The fix has been committed here: https://github.com/purplecabbage/incubator-cordova-wp7/commit/d04b87abb3c3822ef25438e1353a1d7d2e0d6628

You will need to wait for 2.1.0 to be released early next week, or build your app from source-code, in the meantime.

Post a Comment for ""backbutton" Event Won't Fire"