jquery bug fixes / refactoring jquery + erb/routes

I think this has refactoring potential