How would I go about designing a site with a similar layout to Stack Overflow (top menu bar that is always visible) and content body that reloads. I tried using ajax .load() to load in content to the main area but then I have issues with JavaScript not working. How does Stack Overflow accomplish this? I would like to do this in PHP.
Share
That’s definitely a complicated question but I can address your issue with javascript not working, if I understand it correctly.
The problem (in simplified form) is of course that you don’t have some elements (from, for example, “page2”) when you first load the site (which is when JS loads), but when you use ajax.load() to load “page2” instead of “page1” the JS code doesn’t reload and so whatever stuff you were doing with elements on “page2” doesn’t work.
You do have to manually call the relevant functions when you load “page2”. Now, if you just have events (like onclick, etc.) attached to various elements on “page2” then you could use live events in jQuery (if that’s an option), which can be attached to non-existent objects and will become active when the object is created, in this case via ajax.load().