jQuery UI Widgets Forums Editors Button, RepeatButton, ToggleButton, LinkButton getSelection on buttongroup returns null

This topic contains 1 reply, has 2 voices, and was last updated by  Peter Stoev 11 years, 6 months ago.

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author

  • dbs222
    Participant

    Hi. trying to use the getSelection method to id which button in the buttongroup is selected. Code looks like this:

    $(document).ready(function () {
    var theme = getDemoTheme();
    $(“#tpTempPrcpGrp”).jqxButtonGroup({ theme: ‘web’, mode: ‘radio’ });
    });

    $(‘#tpTempPrcpGrp’).on(‘selected’, function () {
    var whichButton = $(‘#tpTempPrcpGrp’).jqxButtonGroup(‘getSelection’);
    alert(whichButton);
    });

    alert returns NULL

    what am I doing wrong? Thanks!

    -david


    Peter Stoev
    Keymaster

    Hi,

    According to me, the problem is the additional }); after the widget initialization.

    Below is a working sample:

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title id='Description'>The jqxButtonGroup widget creates a set of buttons that can work as normal buttons, radio buttons or checkboxes.</title>
    <script type="text/javascript" src="../../scripts/gettheme.js"></script>
    <link rel="stylesheet" href="../../jqwidgets/styles/jqx.base.css" type="text/css" />
    <script type="text/javascript" src="../../scripts/jquery-1.10.1.min.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxcore.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxbuttongroup.js"></script>
    <script type="text/javascript" src="../../jqwidgets/jqxradiobutton.js"></script>
    </head>
    <body class='default'>
    <div id='content'>
    <script type="text/javascript">
    $(document).ready(function () {
    $("#tpTempPrcpGrp").jqxButtonGroup({ theme: 'web', mode: 'radio' });
    $("#tpTempPrcpGrp").on('selected', function () {
    var whichButton = $("#tpTempPrcpGrp").jqxButtonGroup('getSelection');
    alert(whichButton);
    });
    });
    </script>
    <div id='tpTempPrcpGrp'>
    <button style="padding:4px 16px;" id="Left">
    Left</button>
    <button style="padding:4px 16px;" id="Center">
    Center</button>
    <button style="padding:4px 16px;" id="Right">
    Right</button>
    </div>
    </div>
    </body>
    </html>

    Best Regards,
    Peter Stoev

    jQWidgets Team
    http://www.jqwidgets.com/

Viewing 2 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic.