KendoUI移动应用程序,查看事件afterShow无法访问cordova插件。外面的活动很好

时间:2015-03-11 14:27:36

标签: cordova-plugins kendo-mobile telerik-appbuilder

我有一个kendoui applbuilder移动应用程序。我已经安装了一个自定义的camerapreview插件,它工作正常。我尝试在我的视图(afterShow)中添加一个事件处理程序来设置相机插件模块中的内容:

cordova.plugins.camerapreview.startCamera(

初始化相机预览。

问题似乎是在这个处理程序中cordova.plugins.camerapreview未定义?在视图上的按钮处理程序中访问此相同方法可以正常工作。我假设这与依赖有关?我如何确保加载?对我来说,在视图加载并绑定模型后它不可用是没有意义的。

我的代码如下:

// Handle "deviceready" event
document.addEventListener('deviceready', onDeviceReady, false);


var mobileApp = new kendo.mobile.Application(document.body, {

                                                 skin: 'flat',
                                                 initial: 'views/home.html'
                                             });

1 个答案:

答案 0 :(得分:1)

在Cordova中使用Kendo UI Mobile应用时,请务必在 deviceready 事件中初始化应用。这将确保Cordova API在整个应用程序生命周期中都可用。

// this function is called by Cordova when the application is loaded by the device
document.addEventListener('deviceready', function () {  

  // hide the splash screen as soon as the app is ready. otherwise
  // Cordova will wait 5 very long seconds to do it for you.
  navigator.splashscreen.hide();

  app = new kendo.mobile.Application(document.body, {

    // you can change the default transition (slide, zoom or fade)
    transition: 'slide',

    // comment out the following line to get a UI which matches the look
    // and feel of the operating system
    // skin: 'flat',

    // the application needs to know which view to load first
    initial: 'views/home.html'
  });

}, false);