robcrozier Posted November 1, 2011 Share Posted November 1, 2011 I'm building a a fairly large application at the moment and it's going to heavily utilize ajax throughout. What i want to do is structure the application in such a way that it can work well with ajax as well as fall back gracefully if the users browser does not have javascript enabled. I have a nice menu set up and all of the links ar nicely handled via javascript to initiat ajax calls as opose to refresh the page. This works well to get the first load of content into the main interface container. The problem comes when i add the second column which will sit to the right of the interface and be used to house system actions, often CRUD and other relevant actions depending upon what you're looking at. I need to be able, some how to invoke an ajax call to populate this column based upon the information in the main column, which will have already been loaded in via ajax. Furthermore, i need to be able to update the right hand column independently too. I hope this make sense to anyone who has the patience to read it! The main piece of advice i am looking for is.. how can i somehow trigger an ajax call from the content that is loaded in from another whilst not having to write mountains of extra code to handle this if javascript is disabled. Any advice would be great! Thanks Quote Link to comment https://forums.phpfreaks.com/topic/250256-large-ajax-application-structure-advice-needed/ Share on other sites More sharing options...
robcrozier Posted November 1, 2011 Author Share Posted November 1, 2011 OK, what i have came up with is the following... Does anyone have any comments on this at all? In the view script of the first set of ajax loaded content i have: <div class="loadAjaxContent" data-target="#col2"> <h2>Actions</h2> </div> I then have a javascript function set up to listen out for this class being added to the DOM. If it is, it will lad the inner HTML from it into the specified container via ajax. This means that the logic for rendering page actions etc is kept ties to the page that you're actually looking at. Saves a load of generic javascript event listeners to load content in all over the place. What do you guys think of this approach? Any comments? Quote Link to comment https://forums.phpfreaks.com/topic/250256-large-ajax-application-structure-advice-needed/#findComment-1284108 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.