javascript
  • jquery
  • 2016-10-12 5 views -1 likes 
    -1

    私は毎日1つのUserControlを意味する週に5平日、別のUserControlで5回繰り返されるUserControl "Day"を持っています。このユーザーコントロールでRadioButtonListのrdlAmountSlotは、私は上記のコードは、5回の確認ボックスを投げているRadioButtonListのjQueryコードで何が問題なのですか?

    $(document).ready(function(){ 
        $("[id^='rdlAmountSlot_'][type='radio']").change(function() { 
         var radioBtnId = this.id; 
         var $this = $(this); 
         radconfirm('Are you sure you want to select this slot?', function(arg){ 
          if (arg == true) { 
           $find('<%= FindControl("txtAmount").ClientID %>').set_value(""); 
          }  
          else { 
           $this.siblings('input').prop('checked',true); 
           var rdlAmountSlot = document.getElementById(radioBtnId); 
           rdlAmountSlot.checked = false; 
           $this.prop('checked', false); 
          } 
         }, 300, 100,""); 
        }); 
    }); 
    

    ユーザからの確認のために以下のコードを使用する以下のデータ

    rdlAmountSlot_0 - Amount1 --- (1 - 100) 
    rdlAmountSlot_1 - Amount2 --- (100 - 1000) 
    rdlAmountSlot_2 - Amount3 --- (1000 - 10000) 
    rdlAmountSlot_3 - Amount4 --- (10000 - 100000) 
    

    で4回繰り返されました。理由とその解決方法は何か?

    UPDATE以下

    毎日以下

    <asp:UpdatePanel runat="server" ID="pnlUpdate" UpdateMode="Conditional"> 
    <ContentTemplate> 
    <asp:Panel ID="pnlDayView" runat="server"> 
          <asp:RadioButtonList ID="rdlAmountSlot" CssClass="radio1" runat="server" ClientIDMode="Static"> 
          </asp:RadioButtonList> 
    </asp:Panel> 
    </ContentTemplate> 
    </asp:UpdatePanel> 
    

    のための私のマークアップコードは5日

    <table> 
        <tr> 
         <td> 
        <asp:Panel ID="pnlMonday" runat="server" > 
         <uc1:My ID="MyMonday" runat="server" /> 
        </asp:Panel> 
         </td> 
         <td> 
    
        <asp:Panel ID="pnlTuesday" runat="server" > 
         <uc1:My ID="MyTuesday" runat="server" /> 
        </asp:Panel> 
    
         </td> 
         <td> 
    
        <asp:Panel ID="pnlWednesday" runat="server" > 
         <uc1:My ID="MyWednesday" runat="server" /> 
        </asp:Panel> 
    
         </td> 
         <td> 
    
        <asp:Panel ID="pnlThursday" runat="server" > 
         <uc1:My ID="MyThursday" runat="server" /> 
        </asp:Panel> 
    
         </td> 
         <td> 
    
        <asp:Panel ID="pnlFriday" runat="server" > 
         <uc1:My ID="MyFriday" runat="server" /> 
        </asp:Panel> 
    
         </td> 
        </tr> 
        <table> 
    

    これはrdlAmountSlot

    のようなコードであるためのマークアップです
    <table id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability" class="radio1" border="0" style="color: #004B59; font-size: 11px; font-family: Arial, Sans-serif; text-align: justify"> 
              <tr> 
               <td><span disabled="disabled"><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_0" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL01" disabled="disabled" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_0">Slot 0</label></span></td> 
              </tr><tr> 
               <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_1" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL02" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_1">Slot 1</label></td> 
              </tr><tr> 
               <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_2" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL03" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_2">Slot 2</label></td> 
              </tr><tr> 
               <td><input id="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_3" type="radio" name="ctl00$ContentPlaceHolder1$MyAvailability$MyAvailabilityMonday$rdlAvailability" value="AVL04" checked="checked" /><label for="ctl00_ContentPlaceHolder1_MyAvailability_MyAvailabilityMonday_rdlAvailability_3">Slot 3</label></td> 
              </tr> 
             </table> 
    
    +0

    おそらく '$ this.prop( 'checked'、false);' change'イベントを呼び出す – Dimava

    +0

    これは大きな「いいえ」です。私は他のコード全体をコメントしていますが、まだ5回繰り返されています。 –

    +0

    同じIDのラジオボタンが5セットある場合は、問題の原因になっている可能性があります。 4つのラジオボタンの3つのセットを残して、それが3回繰り返すかどうかを確認してください。その場合は、異なるクラス属性を追加して、それに応じて$( "[id^= 'rdlAmountSlot _'] [type = 'radio']")セレクタを変更してください。 –

    答えて

    1

    eachと試してみるといいかもしれません。

    $(document).ready(function(){ 
        $("[id^='rdlAmountSlot_'][type='radio']").each(function() { 
         $(this).change(function(){ 
          var radioBtnId = this.id; 
          var $this = $(this); 
          radconfirm('Are you sure you want to select this slot?', function(arg){ 
           if (arg == true) { 
            $find('<%= FindControl("txtAmount").ClientID %>').set_value(""); 
           }  
           else { 
            $this.siblings('input').prop('checked',true); 
            var rdlAmountSlot = document.getElementById(radioBtnId); 
            rdlAmountSlot.checked = false; 
            $this.prop('checked', false); 
           } 
          }, 300, 100,""); 
         }) 
        }); 
    }); 
    
    +0

    それぞれ4回繰り返す –

    関連する問題