2017-02-19 3 views
0

드롭 다운을 만들기 위해 배열을 추가하는 두 개의 숨겨진 필드를 만들었습니다. select2 배열은 첫 번째 select2에 따라 다릅니다. 따라서 select2를 먼저 호출 할 때 select2 이벤트를 호출하여 다른 select2를 필터링합니다.jQuery Clone 및 select2 이벤트

이 모든 것이 올바르게 작동합니다. 그러나 나는 또한 동일하게 복제하고있다. 그러나 select2의 이벤트를 복제하는 방법을 모르겠습니다. 나는 또한 여과 할 수 없었다. 누군가가 내가 당신의 정확한 욕구를 이해 확실하지 않다 내 jsbin https://jsbin.com/monusupuni/edit?html,js,output

<div class="midcontainer pad20"> 
    <div class="content-area fullWidth whiteBg"> 
     <div class="pad15"> 
      <div class="flightRows"> 
       <div class="row flightRow"> 
        <p><strong><span id="lbFlight">Flight 1</span></strong></p> 
        <div class="depCol1"> 
         <label for="seldcity1" id="lbDeptCity"></label><br> 
         <input type="hidden" id="seldcity1" name="seldcity1" class="styled wth190 seldcity" /> 
        </div> 
        <div class="depCol2"> 
         <label for="selacity1" id="lbArrivalCity"></label><br> 
         <input type="hidden" id="selacity1" name="selacity1" style="width: 210px;" class="styled wth190 selacity" /> 
        </div> 
        <div class="depCol1"> 
         <label for="selddate1" id="lbDeptDate"></label><br /> 
         <input name="selddate1" type="text" id="selddate1" autocomplete="off" class="datepicker calIcon"> 
        </div> 
        <div class="searchBtnHolder"><a href="#" class="addFlightBtn">Add another Flight</a></div> 
        <div class="clear"></div> 
        <hr /> 
       </div> 
      </div> 
     </div> 

답변

0

내 샘플 코드

도움이 될 수 있습니다. 그래도 jQuery clone() 메서드는 withDataAndEvent 및 deepWithDataAndEvent라는 두 개의 인수를 취한다는 것을 알고 계셨습니까?

.clone()을 사용하면 관련된 이벤트가 아닌 요소 만 복제됩니다. 첨부 된 모든 이벤트를 복사하려면 .clone (true, true)을 사용해야합니다.

http://api.jquery.com/clone/

+0

문제가 아니라, 문제는 내가 그 점점되지 복제를 정의해야하는 이벤트입니다 – Milind