0

asp.net我的向导控件中有一些单选按钮。

为了更好地理解标记:

<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>

js事件:

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);
            }
        }

我一直在努力触发这个事件,也尝试了可能的方法来做到这一点:

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

});

但它还没有准备好开火,有什么帮助吗?

4

5 回答 5

2

我试试你的代码,似乎“appendChild”是一个内置的 js 函数,给我带来了错误,所以当我将它的名称更改为“appendChild1”之类的其他东西时,它工作正常,试一试......

于 2012-12-26T06:50:23.710 回答
1

你可以试试下面的代码

$('#<%=dvFolderOptions.ClientID %> li input:radio').click(function()
{
appendChild(this);
}
于 2012-12-26T06:25:56.523 回答
1

将您的函数名称 appendChild 更改为任何其他名称,因为 appendChild 已经存在于 javascript 中

改变 这个

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

function appendMyChild(crnt) {
    // code goes here
}
于 2012-12-26T06:48:32.543 回答
0

试试这个

$('[id$=dvFolderOptions]').delegate('li input:radio', 'click', function(){ 
            appendChild(this);
            alert('1+2+3');
        });
于 2012-12-26T06:28:29.403 回答
0

用这个

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

代替

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

我刚刚测试,它的工作原理!

于 2012-12-26T06:28:38.873 回答