Fixed Edit mode problem, Moved js into view.js