Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

losing css after jquery ajax load

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

like image 818
user765368 Avatar asked Feb 08 '12 14:02

user765368


1 Answers

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.

like image 67
Diodeus - James MacFarlane Avatar answered Oct 05 '22 11:10

Diodeus - James MacFarlane