2014-06-24 2 views
0

외부 파일에서 콘텐츠를로드 할 때 Jquery 기능이 작동하지 않습니다.외부 파일에서로드 할 때 jquery 함수를 활성화하는 방법은 무엇입니까?

Index.php는

<div id="sub_page" > 
</div> 
<a href="#" onClick="sub_page(test,"1")"> Load Div</a> 

<script type="text/javascript"> 

function sub_page(con,id) { 
$("#sub_page").html('<br><br><img src="/img/custom/loader.gif" /> &nbsp;Please Wait...<br><br> '); 
$("#sub_page").load('/function/code.php?con='+ con + "&id=" + id); } 

$('#datepicker').datetimepicker({ 
    yearOffset:0, 
    lang:'en', 
    timepicker:false, 
    format:'d/m/Y', 
    formatDate:'Y/m/d', 
    minDate:'-2013/01/01', // yesterday is minimum date 
    maxDate:'+2015/01/01' ,// and tommorow is maximum date calendar 
    mask:'99/19/3939' 
}); 
</script> 

code.php

<input type="text" id="datepicker" value=""> 

i가 작동하지 않습니다 code.php 날짜 선택기의 JQuery와 기능에서 DIV를로드하려합니다. 하지만 index.php 코드를 붙여 넣으려고 할 때 작동합니다.

작업 코드

<div id="sub_page" > 
<input type="text" id="datepicker" value=""> 
    </div> 

    <script type="text/javascript">   
    $('#datepicker').datetimepicker({ 
     yearOffset:0, 
     lang:'en', 
     timepicker:false, 
     format:'d/m/Y', 
     formatDate:'Y/m/d', 
     minDate:'-2013/01/01', // yesterday is minimum date 
     maxDate:'+2015/01/01' ,// and tommorow is maximum date calendar 
     mask:'99/19/3939' 
    }); 
    </script> 

같은이 오류를 해결하는 데 도움이 바랍니다. 로드가 완료되면

답변

0

봅니다 날짜 선택기 호출 :

$("#sub_page").load('/function/code.php?con='+ con + "&id=" + id, function() { 

    $('#datepicker').datetimepicker({ 
     yearOffset:0, 
     lang:'en', 
     timepicker:false, 
     format:'d/m/Y', 
     formatDate:'Y/m/d', 
     minDate:'-2013/01/01', // yesterday is minimum date 
     maxDate:'+2015/01/01' ,// and tommorow is maximum date calendar 
     mask:'99/19/3939' 
    }); 

}); 
관련 문제