Jump to content

large ajax application... structure advice needed


robcrozier

Recommended Posts

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

 

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.