Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Include jscolor in ajax loaded page

I have a index.php page and I am inluding other pages in index.php like this:

function urlpage(url){
    $('#page').load(url);
}

jscolor javascript working in index.php but when I load a page (test.php) jscolor not working in this loaded page. What can I do?

I added also this in test.php :

<script type="text/javascript" src="js/jscolor.js"></script>

EDİT : I solved the problem like this :

test.php

<script type="text/javascript">
    $(document).ready(function() {
        jscolor.init();
    });
</script>
like image 236
webmaster Avatar asked Oct 23 '25 06:10

webmaster


2 Answers

jscolor.init() did not work for me, and So I called

jscolor.installByClassName("jscolor");

$(document).ready(function() {
  jscolor.installByClassName("jscolor");
});

Hope it helps

like image 84
vishal shah Avatar answered Oct 25 '25 20:10

vishal shah


You can try to reinitialize jscolor once your load function is done.

$('#page').load(url, function () {
    var myPicker = new jscolor.color($('#myField'), {})
});

Also check other examples.

like image 28
Justinas Avatar answered Oct 25 '25 19:10

Justinas