javascript src does not work from parent jquery load -


i have parent container loading in child container has javascript src pointing library. when child loaded, src library not run.
tried getscript() after callback not have affect.

library color picker: http://jscolor.com/

suggestions please?

parent.html:

<html lang="en-us">   <head>     <meta charset="utf-8">     <script src="http://code.jquery.com/jquery.min.js"></script>     <script type="text/javascript">       $(function(){         $('#rec').load('child.html', function(){           $.getscript("js/jscolor.js");         });       });     </script>   </head>   <body>     <div id='rec'></div>   </body> </html> 

child.html:

<script type="text/javascript" src="js/jscolor.js"></script> <input class="color" value="66ff00"> 

jscolor.js needs loaded before document completly loaded because attach stuffs input element using onload event of document, in case document loaded when load jscolor.js. call jscolor.init again after $.getscript("js/jscolor.js") has loaded js file.

$(function(){ $('#rec').load('child.html', function(){    $.getscript("js/jscolor.js", function(data, textstatus, jqxhr) {        jscolor.init(); }); 

Comments