从外部文件加载时如何激活jquery函数?

Jquery function is not working when i am loading content from external file.

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="">

When i am trying to load div from code.php datepicker jquery function is not working. But when i am trying to paste code to index.php itself it is working. Like

Working Code

<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>

So please help me to correct this Error.

Try to call datepicker once the load is complete :

$("#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'
    });

});