Question

I am really new to appMobi, HTML and JavaScript. The only thing I want to do is that I have a button with an onClick method and this method should do anything. I have defined a Script, I have a button but the method doesn't get called. Can someone please tell my why? The examples provided by appMobi don't do anything different - I think. Here is my code:

    <head>
    <!-- the line below is required for access to the appMobi JS library -->
    <script type="text/javascript" charset="utf-8" src="http://localhost:58888/_appMobi/appmobi.js"></script>

    <script type="text/javascript" language="javascript">
        // This event handler is fired once the AppMobi libraries are ready
        function onDeviceReady() {
            //use AppMobi viewport to handle device resolution differences if you want
            //AppMobi.display.useViewport(768,1024);

            //hide splash screen now that our app is ready to run
            AppMobi.device.hideSplashScreen();
        }

        //initial event handler to detect when appMobi is ready to roll
        document.addEventListener("appMobi.device.ready",onDeviceReady,false);
        function myfunction(){
            AppMobi.debug.log("test");
            alert("Hallo Welt");

        }

    </script>


    <script type="text/javascript">

        function myfunction(){
            AppMobi.debug.log("test");
            alert("Hallo Welt");
        }
        </script>

</head>
<body >
    <br>

       <button onclick="myfunction();">MyButton</button>

</body>
Was it helpful?

Solution

Finally, I found the solution! Instead of onclick="myfunction" you have to use ontouchstart="myfunction"!
Would be nice if someone could tell me why.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top