                 (let [dt (getdata json)]
                   (set-key-value :documents dt)
                   (set-key-value :total-pages (get-total-rec-no dt))
-                  (r/render [render-documents (get-new-page-data (get-value! :documents)
-                                                                 (get-value! :current-page))]
-                            (.getElementById js/document "app1"))
-                  (r/render [shared-state 0]
-                            (.getElementById js/document "pindex"))))]
+                  (set-key-value :page-location
+                                 (render-documents
+                                  (get-new-page-data
+                                   (get-value! :documents)
+                                   (get-value! :current-page))))))]
     (http-get "http://localhost:8193/documents/all" onres)))
 
 (defroute documents-path "/documents/add" []
-  (r/render-component [document-template] (js/document.getElementById "add")))
+  (set-key-value :page-location [document-template]))
 
 (defroute documents-path1 "/documents/update/:id" [id]
-  (r/render [document-update-template id
-             (first (filter (fn[obj]
-                              (=(.-id obj) (.parseInt js/window id))) (get-value! :documents)))]
-            (js/document.getElementById "update")))
+  (set-key-value :page-location
+                 [document-update-template id
+                  (first (filter (fn[obj]
+                                   (=(.-id obj) (.parseInt js/window id))) (get-value! :documents)))]))
 
 (defroute "*" []
   (js/alert "<h1>Not Found Page</h1>"))
+
 
 (defn main
   []
   (secretary/set-config! :prefix "#")
+  (set-key-value :page-location [render-documents []])
+  (r/render [page]
+            (.getElementById js/document "app1"))
   (let [history (History.)]
     (events/listen history "navigate"
                    (fn [event]

                           (let [i (.-eventKey s2)]
                             (do
                               (set-key-value :current-page i)
                               (r/render [render-documents (get-new-page-data (get-value! :documents)
                                                                              (get-value! :current-page))]
                                         (.getElementById js/document "app1")))))}])




   :location (getinputvalue "location") })

(defn save [event]
  (let [onres (fn[json] (do
                         (set-key-value :documents (getdata json))
                         (set-key-value :page-location
                                        [render-documents (get-new-page-data (get-value! :documents)
                                                                             (get-value! :current-page))])))]
    (http-post "http://localhost:8193/documents/add"
               onres  (.serialize (Serializer.) (clj->js (get-documents-formdata))))))

