I'm having some trouble trying to organize a bunch of ajax calls I have on my index page of a record submission application. This is what I'm trying to do:
I have a list on my /index page that hold a list of items I have in a database. This list is generated by django when I send an ajax call to /show_list and then load it into the on the /index page
I have a fancy modal window that pops up on the same /index page in order to add items to the database. This form, which is programmed in the /index page, gathers user input and sends it off to /add_item to load it into the database.
Within this list that is described in the /show_list template, I have edit functions to alter each individual record, which fill in the above form, so the user can easily edit existing information. But now, I have /show_list code reaching into /index to alter the form information. The edited information is passed back to /add_item (but is actually editing it), and then /index calls for /show_list to refresh itself.
I can see that this is incredibly disorganized and annoying to keep track of. I end up with a ton of code in the $.ajax{success: function(){ ... } } section, which doesn't seem right to me.
Is there a better way to arrange this sort of behavior?