ankur
ankur

Reputation: 4733

radio button click event not firing

There are some radio buttons inside my asp.net wizard control.

For better understanding Markup:

<asp:Wizard ID="WizardCreateDL" runat="server" ActiveStepIndex="0" BackColor="#F7F6F3"
        BorderColor="#CCCCCC" BorderWidth="1px" Font-Names="Calibri" Font-Size="0.8em"
        Height="337px" Width="800px" OnNextButtonClick="WizardCreateDL_NextButtonClick"
        OnCancelButtonClick="WizardCreateDL_CancelButtonClick" OnPreviousButtonClick="WizardCreateDL_PreviousButtonClick"
        DisplaySideBar="False" BorderStyle="Solid" OnFinishButtonClick="WizardCreateDL_FinishButtonClick">
        <StepStyle BorderWidth="0px" />
        <WizardSteps>
            <asp:WizardStep ID="stepCreateFolder" runat="server" Title="FolderOptions" >
                <div id="dvFolderOptions" runat="server" style="text-align: left; width: 45%; margin: auto; font-size:medium">
                    <ul style="list-style: none;">
                        <li>
                            <input type="radio" id="rdbCalendar" value="0" name="Cal" onclick="appendChild(this);" /><label for="rdbCalendr">Calendar</label></li><br />
                        <li>
                            <input type="radio" id="rdbTasks" value="0" name="Cal" onclick="appendChild(this);"  /><label for="rdbTasks">Tasks</label></li><br />
                        <li>
                            <input type="radio" id="rdbContacts" value="0" name="Cal" onclick="appendChild(this);"  /><label for="rdbContacts">Contacts</label></li>
                    </ul>
                </div>
            </asp:WizardStep>
        </WizardSteps>
        <StartNavigationTemplate>
            <asp:Button ID="StepNextButton" runat="server" CausesValidation="False" CommandName="MoveNext"
                Font-Names="Calibri" Font-Size="1.3em" Text="Next" Visible="false" />
            <asp:Button ID="btnFinish" runat="server" Font-Names="Calibri" Font-Size="1.3em"
                Text="Finish" Visible="false" CausesValidation="False" OnClick="btnFinish_Click" />
        </StartNavigationTemplate>
    </asp:Wizard>

The js event:

function appendChild(crnt) {
            alert('hi');
            var parentLi = $(crnt).parents('li:first');
            if (parentLi.find('ul:first').length == 0) {
                var Container = $('<ul></ul>').append('<li><input type="radio" id="rdbEditor" value="0" onclick="secondLevelChild();" /><label for="rdbEditor">Editor</label></li><li><input type="radio" id="rdbReviewer" value="0" onclick="secondLevelChild();"  /><label for="rdbReviewer">Reviewer</label></li>')
                parentLi.html(Container);
            }
        }

i have been struggling to fire this event , tried also possible ways to do this like :

$(function () {
  $('#ContentPlaceHolder1_WizardCreateDL_dvFolderOptions').find('li').each(function   () {
        $(this).find('input:radio').click(function () {
            appendChild(this);
            alert('1+2+3');
        });
    });

});

but it is just not ready to fire, any help??

Upvotes: 0

Views: 1249

Answers (5)

Anil D
Anil D

Reputation: 2009

i try you code, seems like "appendChild" is a built in js function , giving error for me, so when i changes its name to some thing else like "appendChild1" its worked fine, give it a try...

Upvotes: 2

rajesh kakawat
rajesh kakawat

Reputation: 10896

Change your function name appendChild to any other name becoz appendChild is already present in javascript

change This

function appendChild(crnt) {
    // code goes here
}

To

function appendMyChild(crnt) {
    // code goes here
}

Upvotes: 1

Rohit Patel
Rohit Patel

Reputation: 459

Use this

$('#<%=dvFolderOptions.ClientID %>').find('li').each(function () {

instead of

$('#ContentPlaceHolder1_WizardCreateDL_dvFolderOptions').find('li').each(function   () {

I just tested and it works!

Upvotes: 0

rs.
rs.

Reputation: 27427

Try this

$('[id$=dvFolderOptions]').delegate('li input:radio', 'click', function(){ 
            appendChild(this);
            alert('1+2+3');
        });

Upvotes: 0

Murali Murugesan
Murali Murugesan

Reputation: 22619

Can you try below code

$('#<%=dvFolderOptions.ClientID %> li input:radio').click(function()
{
appendChild(this);
}

Upvotes: 1

Related Questions