Cannot perform .change method on horizontal radio buttons

rss

Posted by Jdubs - Jul 29 ’15 at 04:05

I'm using the following code to make my Radio buttons horizontal per another thread on here:

 

//Horizontal Radio Buttons

var rows = fd.field('Action').control()._el().find('table tr td');

fd.field('Action')

.control()

._el()

.find('table > tbody')

.empty()

.append($('<tr />').append(rows));

 

However, when I use this code, I can no longer perform a .change Method on the field in question:

 

//Test change method

fd.field('Action').change(function() {

z = fd.field('Action').value();

alert(z);

});

However, when I remove the horizontal code, the change method works as intended. Any way around this?

 

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 11 months 4 days
    #1 by rostislav Jul 30 ’15 at 07:36

    I copy-pasted in your code and it works as expected. Are you using correct InternalName values?

  • Jdubs
    Member
    Member for: 5 years 3 months 22 days
    #2 by Jdubs Jul 30 ’15 at 08:28

    [#1]: Yes, the correct internal name is Action (with no spaces/underscores/special characters).

    And my code works, just not in conjunction with the code that makes the radio buttons horizontal.

     

    Here's how to reproduce the error:

    1. Create "Choice" SharePoint field, name it whatever (in this case, "Action"), and select either "Checkbox" or "Radio button"
    2. Insert following JavaScript Code:

    //Horizontal Radio Buttons

    /*var rows = fd.field('Action').control()._el().find('table tr td');

    fd.field('Action')

    .control()

    ._el()

    .find('table > tbody')

    .empty()

    .append($('<tr />').append(rows));/*

    3.  Now insert another code snippet:

    //Test change method

    fd.field('Action').change(function() {

    z = fd.field('Action').value();

    alert(z);

    });

    4.  Open Form, and change the value in the "Action" checkbox/radio button.

    5.  The code does not fire.

    6.  (If I remove the code listed in Step 2, the code does fire.)

  • rostislav
    rostislav
    Moderator
    Member for: 4 years 11 months 4 days
    #3 by rostislav Jul 31 ’15 at 04:41

    [#2]:

    I've tested all of the code you posted in the first post and it works fine for me.  Please send use the html source code of your page to [email protected]

Displaying 1 to 3 of 3 messages