Button click calling javascript method

5 posts, 1 answers
  1. Jason
    Jason avatar
    20 posts
    Member since:
    Nov 2011

    Posted 03 Aug 2012 Link to this post


    I have a "sign in" button on a view and when a user clicks on it, I want it to run a javascript method. It seems simple and I have a sample one page app which works. However my actual app is several pages and for some reason the same html doesn't work when I copy it from the sample page to the real app. I'm currently trying 3 ways to call the javascript method, but i think the first one is the right way.

    <data-role="button" data-click="signInButton">Sign In</a>
    <data-role="button" href="javascript:signInButton();">Sign In 2</a>
    <data-role="button" onclick="signInButton()">Sign In 3</a>

    And the javascript is currently very simple, just popup and alert so I know the method got called and navigate to another view.

    function signInButton(e{

    Here is the current app http://jsfiddle.net/jwhitmer/vsPye/

    A few other forum posts helps me get this far. It runs on iPhone, iPad, Android phone and Blackberry phone. I'm amazed at what Kendo UI can do with so little coding on my part.

    Thank you for any guidance,
  2. Answer
    Petyo avatar
    2436 posts

    Posted 06 Aug 2012 Link to this post

    Hello Jason,

    The first button uses the correct syntax for event handling. There is a catch in jsFiddle though, which scopes the functions in it javascript panel. I updated your jsfiddle to output the scripts in the body, and it works now.


    the Telerik team
    Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
  3. Jason
    Jason avatar
    20 posts
    Member since:
    Nov 2011

    Posted 06 Aug 2012 Link to this post

    Thank you, Peyto. Its working great now.
  4. John
    John avatar
    12 posts
    Member since:
    Nov 2012

    Posted 08 Nov 2012 Link to this post

    Can you pass an argument in the Kendo UI data-click? What is the best practice on passing arguments? 

    <a data-role="button" data-click="updateShowButtonGroup('Test');">test</a>

    <script> updateShowButtonGroup(tmp){


    thank you,
  5. Michael Rogers
    Michael Rogers avatar
    22 posts
    Member since:
    Mar 2010

    Posted 14 Nov 2012 Link to this post

    I also have the same question as John.  When i do it this way the button only works if i click on the very edges of it if i click on the text it never fires the JS


    <ul data-role="listview" data-style="inset" id="lvRASServers" data-bind="source: RASServer" data-template="RASServers-template" >
                    <script id="RASServers-template" type="text/x-kendo-template">
                        <a data-role="button" class="rdpButton" onClick="startRDP('${RASServerHostname}')">Connect</a>                                              
Back to Top