JS and Cordova / Onsen questions

  • Where can I find a reference to all the possible events and their arguments? I am writing my code in pure JS.

    I basically can’t figure out what goes where and would appreciate a reference to how to code using the Onsen UI 2 framework.

    I was looking at pure Cordova before and also noticed different init events between the two. Are they interchangeable or complimentary? Thanks!

  • @alexej Onsen “wraps” Cordova events so to speak, so when you use Onsen, you just need to worry about their events. Here are some resources to get you started and YAY! You are using Vanilla JS - it seems like everyone is wanting all sorts of other frameworks these days.




    There are a lot of really good questions and answers in these forums. If you encounter a problem, post some code and let us know!

  • Thanks! So it is correct to add document.addEventListener("deviceready", onDeviceReady, false); to the .js file? I am interested in the Cordova “resume” event for example.

  • @alexej Basically you would use:

     document.addEventListener("deviceready", onDeviceReady, false);
    function onDeviceReady() {
        document.addEventListener("resume", onResume, false);
        // Add similar listeners for other events
    function onResume() {
        // Handle the resume event

    More information can be found here: https://cordova.apache.org/docs/en/latest/cordova/events/events.html

Log in to reply