                  onres  (.serialize (Serializer.) (clj->js @data-set))))
     (reset! focus "on")))
 
+(defn update-form-onclick [data-set focus]
+  (if (= nil (form-validator @data-set))
+    (let [onres (fn[data]
+                  (secretary/dispatch! "/documents"))]
+      (http-post "http://localhost:8193/documents/update"
+                 onres (.serialize (Serializer.) (clj->js @data-set))))
+    (reset! focus "on")))
+
 (defn form-cancel [event]
   (secretary/dispatch! "/documents"))
 
-(defn document-template-form [doc-name data-set focus]
-  [:div#add.container
+(defn document-template [doc-name data-set focus save-function]
+  [:div.container
    [:div.panel.panel-primary.model-dialog
     [:div.panel-heading
      [:h2 doc-name]]

                                           (get-value! :current-page))]))))

;; ========================================================================================
;; Add and Update form creation validation
;; ========================================================================================

(defn form-validator [data-set]



(defroute documents-path "/documents/add" []
  (set-page! [document-add-template]))

(defroute documents-path1 "/documents/update/:id" [id]
  (set-page! [document-update-template id
              (first (filter (fn[obj]
                               (=(.-id obj) (.parseInt js/window id))) (get-value! :documents)))]))

