Tony
Tony

Reputation: 12705

Dynamic loaded page doesn't re-bind the JS code

I have that scenario. I load dynamically the Page A which contains some JS code. Inside that page, I can dynamically load another Page B (which can be also dynamically removed by using fadeOut effect and .remove() function)

The Page B contains a jQUery's UI datepicker plugin (and also some other plugins).

And here's the thing: if I load the Page B, the datepicker is initialized properly, but if I remove that Page B and re-load it, that datepicker is not being initialized. Why ?

I'm using the .datepicker("destroy") function and then .datepicker({...}) inside the Page B but without any effect.

Upvotes: 0

Views: 35

Answers (1)

Fseee
Fseee

Reputation: 2627

try importing your B js in the A js like this:

$.getScript("yourOwnPath/theB.js", function() {
        });

Upvotes: 1

Related Questions