does everybody know how to fix the problem of css after an Ajax request with $.load? For example, If I want to load just a DIV from a webpage, after my Ajax request with:
$('container').load('path_to_div #div_id');
I lose all the css and scripts that was associated with that div
Any idea please
Yes, any event handlers that were attached will be disconnected when content is replaced by AJAX. You can use jQuery's .on()
or .live()
as alternative event hooks to prevent this.
As for the CSS, you've probably got a class name or ID on the original content that's missing on the replaced content, or the replaced content does not match the same selectors you set up in your CSS.
Without seeing your HTML/CSS it's impossible to tell.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With