Friday, October 14, 2011

My javascript stack

Ok so here’s how I’m building my single page business app.

Backend is asp.mvc using fubu html helpers. 

front end.  Here are the plug ins I’m using. jquery ( of course ), backbone.js, a little pub sub class, $.address, knockout.js and my own system of controllers.

A lot of people talk about not using any controller, just straight backbone.js or knockout.js.  I can’t seem to figure this out.  My shit has lots of stuff going on that has no place in a view or a model but I don’t want it just hanging around willy nilly.  I need a freakin controller to manage all the different parts. 

For instance, when you click on a row in the grid, it must hide the grid and show a form.  When the form submitted or canceled it should remove the form and show the grid again.

First I hide the grid so that I don’t have to re load that section.  If the form is updated rather then canceled I update the grid but I don’t have to get the whole def and re render everything.  The form however, I retrieve via ajax.  This is because there could be different forms based on what exactly is clicked on the page/grid and loading a form for every possible outcome is crazy.

Even so that might not seem like it’s that crazy that I just absolutely need a controller, but here’s a real example of the basic page in out app.  We a) load a grid. click on the grid and you get b) ajax call for form. On the form there is the ability to associate a document with this particular instance of the entity.  If you haven’t any you can upload a new one.  But you can’t just upload a document you much attach some meta data to the document so we need a c) new ajax form and a d) new popup to house it.  then you save the doc and meta data and you see it in a list of selected documents for this item.  If you want to edit/view one of these docs you can click on the name and up comes the popup with the form and data.  This is the basic page and shit just gets more complex from there. 

So in my next post I’ll explain my controller and how it keeps me sane.  But it’s friday 6:00 and I still got shit to do so I’m out.

No comments: