Childbrowser插件无法在Phonegap中运行

时间:2012-04-12 10:06:24

标签: ios5 cordova backbone.js requirejs

我正在使用与Phonegap或Cordova捆绑的Backbone,Require和Underscore。

我尝试使用childbrowser插件,但它无法正常工作。我按照这里的说明操作。 http://blog.digitalbackcountry.com/2012/03/installing-the-childbrowser-plugin-for-ios-with-phonegapcordova-1-5/

define([
'jquery',
'backbone',
'underscore',
'base64',
'mobile',
'const',
    'child',
'text!template/login/login.tpl.html'
],function($, Backbone, _, base64, Mobile, Const, ChildBrowser, template){

var EncodeAuth = function(user,pass)
{
    var _tok = user + ':' + pass;
    var _hash = Base64.encode(_tok);
    return "Basic "+ _hash;
}

var LoginView = Backbone.View.extend({
    events:{
    "click .login-btn" : "Login",
    "click .connection-btn" : "OpenSite"
    },

    initialize: function(){
    },

    Login: function(){
        Const.USERNAME = $("#username").val();
        Const.PASSWORD = $("#password").val();
        if(!Const.USERNAME || !Const.PASSWORD)
        {
            navigator.notification.alert("Invalid Username/Password!");
            $("input").val("");
        }else{

            var auth = EncodeAuth(Const.USERNAME,Const.PASSWORD);

            var sendAuthorization = function (xhr) {
              xhr.setRequestHeader('Authorization', auth)
            };

            this.model.save(this.model, {
                beforeSend : sendAuthorization,
                success: function(model,result){
                    if(result.ErrorMessage === null)
                    {
                        alert(JSON.stringify(result.Message));
                        $("input").val("");
                    }
                    else
                    {
                        alert(JSON.stringify(result.ErrorMessage));
                        $("input").val("");
                    }
                },
                error: function(model,result){
                    alert("Remote server returned an error. Not Found");
                    $("input").val("");
                }
            });
        }
    },
        OpenSite: function(){
            window.plugins.ChildBrowser.showWebPage("http://www.google.com");
        }
});
return LoginView;
 });

有什么想法吗?

0 个答案:

没有答案