jQWidgets Forums

jQuery UI Widgets Forums Editors CheckBox, RadioButton Dynamically Assigned Radio Buttons and Radio Button Groups

Tagged: 

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

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

  • jcdesigndesk
    Member

    Hello,

    I need to be able to initialize radio buttons with groups dynamically after adding the divs with the correct attributes to the html.

    Below is an example of the code I am currently using to attempt to initialize the widgets, but it is not working with the variables in place of static ID names.

    Is it possible for jQWidgets to initialize dynamically in this fashion?

    var radiobuttons = document.getElementsByClassName(‘optionsradio’);

    $(radiobuttons).each(function (){

    var radioGroup = $(this).attr(‘id’);
    var radioGroupName = $(this).attr(‘group’);

    $(radioGroup).jqxRadioButton( { groupName: group , theme:’black’, width:205, checked:false } );

    });


    Peter Stoev
    Keymaster

    Hi,

    The “var radioGroup = $(this).attr(‘id’);” will return ID. To make a jQuery selection by id, you should use $(“#ID”), not $(“ID”) so the $(radioGroup) jQuery selection is incorrect. It should be most probably: $(“#” + radioGroup)

    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.