2015-01-21 3 views
-1

вызов функции jquery внутри ретранслятора. Проблема я хочу переключить div, когда нажимаем на ссылку. Я думаю, что не первая функция jquery с этим случаем. Я думаю, что также зонд из таблицы между div и ссылкой.Вызов функции 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

Итак, чего вы хотите достичь? Когда я нажимаю «Адресные данные», ссылка должна открыться? Пожалуйста, сообщите нам правильные данные – BNN

+0

, когда я нажимаю на ссылку, открываю div. – boshkash

ответ

0

Проблема была toggleMe() функция. Если вы хотите, переключаясь в DIV, что вам нужно сделать что-то вроде этого: -

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

Надеется, что это помогает.

+0

и что я делаю в кнопке события onclientclick – boshkash

+0

Я думаю, что вам это не нужно. Он работает' onClick' кнопки – BNN

+0

, потому что пост назад открывает все div – boshkash

Смежные вопросы