diff --git a/source/clog-base.lisp b/source/clog-base.lisp index b4316ff..8141184 100644 --- a/source/clog-base.lisp +++ b/source/clog-base.lisp @@ -84,6 +84,16 @@ during attachment. (Private)")) "'body'" (format nil "clog['~A']" (html-id obj)))) +;;;;;;;;;;;;;;;;;;; +;; cached-excute ;; +;;;;;;;;;;;;;;;;;;; + +(defun cached-execute (connection-id script) + "Excute SCRIPT on browser, if connection cache enabled use. (Private)" + (if *connection-cache* + (push script *connection-cache*) + (clog-connection:execute connection-id script))) + ;;;;;;;;;;;;;;;; ;; js-execute ;; ;;;;;;;;;;;;;;;; @@ -93,9 +103,7 @@ during attachment. (Private)")) discarded, return CLOG-OBJ. (Internal)")) (defmethod js-execute ((obj clog-obj) script) - (if *connection-cache* - (push script *connection-cache*) - (clog-connection:execute (connection-id obj) script)) + (cached-execute (connection-id obj) script) obj) ;;;;;;;;;;;;;; diff --git a/source/clog-element.lisp b/source/clog-element.lisp index bedd319..56a26cd 100644 --- a/source/clog-element.lisp +++ b/source/clog-element.lisp @@ -49,8 +49,7 @@ clog array but is not in the DOM. If HTML-ID is nil one is generated. (let ((web-id (if html-id html-id (format nil "CLOG~A" (generate-id))))) - (clog-connection:execute - connection-id + (cached-execute connection-id (format nil "clog['~A']=$(\"~A\").get(0); $(clog['~A']).first().prop('id','~A')" web-id html web-id web-id)) @@ -63,7 +62,7 @@ clog array but is not in the DOM. If HTML-ID is nil one is generated. (defun attach (connection-id html-id) "Create a new clog-obj and attach an existing element with HTML-ID on CONNECTION-ID to it and then return it. The HTML-ID must be unique. (private)" - (clog-connection:execute connection-id + (cached-execute connection-id (format nil "clog['~A']=$('#~A').get(0)" html-id html-id)) (make-clog-element connection-id html-id))