This is a migrated thread and some comments may be shown as answers.

Can't call javascript

2 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Kennet
Top achievements
Rank 2
Kennet asked on 28 Nov 2012, 03:36 PM
When I use "onclick" then first time it will not fire, the second time it fires but then my other links stop working,

I use PhoneGap/Cordova on Android

Any suggestions? Here is my code:
<!DOCTYPE html>
<html>
<head>
    <title>TEST</title>
 
    <script src="cordova-2.2.0.js"></script>
 
    <script src="js/jquery.min.js"></script>
    <script src="js/kendo.mobile.min.js"></script>
 
    <link href="css/kendo.common.min.css" rel="stylesheet" />
    <link href="css/kendo.mobile.all.min.css" rel="stylesheet" />
</head>
 
<body>
     
    <div id="div1" data-role="view" data-title="Hello World">
     
    <h2>Hello App</h2>
 
    <ul data-role="listview" data-style="inset" data-type="group">
        <li>Please select:
            <ul>
                <li data-icon="play"><a href="Page1.html">Page 1</a></li>
             
                <li data-icon="play"><a href="#" onclick="test1();">Test</a></li>
            </ul>
        </li>
    </ul>
</div>
 
 
 
    <script>
        window.kendoMobileApplication = new kendo.mobile.Application(document.body);
         
        function test1()
        {
            alert('hello there...');
        }
         
    </script>
     
 
</body>
</html>

2 Answers, 1 is accepted

Sort by
0
Kennet
Top achievements
Rank 2
answered on 28 Nov 2012, 04:21 PM
OK so I got it working with data-click, but only on a button not an listview

This works
<a class="button" data-role="button" data-click="test1">Test 1</a>
This don't...
<ul>
    <li><a data-click="test1">Test 1</a></li>
    <li><a data-click="test2">Test 2</a></li>
                 
    <li><a href="#:back">Menu</a></li>
</ul>
 
<script>
    function test1() {
       alert('test1...');
    }
 
  function test2() {
       alert('test2...');
    }
</script>

0
Petyo
Telerik team
answered on 29 Nov 2012, 09:19 AM
Hello Kennet,

The recommended approach in this case would be to use the listview click event to handle clicks of items in listview. 

All the best,
Petyo
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
General Discussions
Asked by
Kennet
Top achievements
Rank 2
Answers by
Kennet
Top achievements
Rank 2
Petyo
Telerik team
Share this question
or