2015-01-21 3 views
-1

리피터 내부에서 jquery 함수 호출하기. 링크 버튼을 클릭 할 때 div를 토글하고자 할 때 .i이 경우 첫 번째 jquery 함수 사용을 생각하면 안된다. div와 link 버튼 사이의 테이블에있는 probelem을 생각해보십시오.리피터 내부에서 JQuery 함수 호출하기

function toggleMe() { 
     $(function() { 
      $('.toggler').on('click', function (ev) { 
       $(this).next('.dataContentSection').toggle(); 
      }); 
     }); 
     } 
<div id="repeater"><div class="dataContentSection"> 
    <div>Name</div> 
</div> 

     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label1" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label2" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label3" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label4" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
<div class="dataContentSection"> 
    <div>Name</div> 
</div> 
     <table> 
      <tr> 
       <td> 
        <asp:LinkButton class="titleText toggler" OnClientClick="javascript:toggleMe(); return false;" runat="server">+ Address details</asp:LinkButton> 

        <asp:Label ID="Label5" runat="server" Text="Welcome"></asp:Label> 

       </td> 
      </tr> 
     </table> 
<div class="dataContentSection" style="display: none;"> 
    <div>Address Line 1:</div> 
    <div>Address Line 2:</div> 
    <div>Address Line 3:</div> 
</div> 
</div> 
+0

뭐죠? – atmd

+0

그래서 달성하고자하는 것은 무엇입니까? 'Address Details'를 클릭하면 링크가 열리나요? 제발 우리에게 세부 사항을 적절하게 – BNN

+0

내가 linkbutton을 클릭 div를 클릭하십시오. – boshkash

답변

0

문제는 toggleMe() 기능이었다. 당신이 사업부의 토글 링을 원하는 경우 , 당신은 같은 것을 할 필요가 : -

$(function() { 
     $('.toggler').click(function (ev) { 
      $(".dataContentSection").toggle(); 
      $(this).next('.dataContentSection').toggle(); 
     }); 
    }); 

희망이 도움이됩니다.

+0

도 제공 할 수 있습니까? 그리고 onclientclick 이벤트 버튼에서 무엇을합니까? – boshkash

+0

필요하지 않습니다. 버튼의'onClick'이 – BNN

+0

으로 작동하기 때문에 포스트가 모든 div의 – boshkash

관련 문제