mirror of
https://github.com/rabbibotton/clog.git
synced 2026-02-02 22:03:25 -08:00
Fix attach
This commit is contained in:
parent
ea8cf343ba
commit
0c3a6fa504
2 changed files with 26 additions and 9 deletions
24
clog.lisp
24
clog.lisp
|
|
@ -38,8 +38,9 @@ application."
|
|||
"CLOG Obj"
|
||||
(clog-obj class)
|
||||
|
||||
"CLOG Obj - Creation Methods"
|
||||
"CLOG Obj - Low Level Creation Methods"
|
||||
(create-child (method () (clog-obj t)))
|
||||
(attach-as-child (method () (clog-obj t)))
|
||||
|
||||
"CLOG Obj - Placement Methods"
|
||||
(place-after (method () (clog-obj t)))
|
||||
|
|
@ -111,12 +112,24 @@ lisp and the HTML DOM element."))
|
|||
|
||||
(export 'create-child)
|
||||
(defmethod create-child ((obj clog-obj) html &key (auto-place t))
|
||||
"Create HTML element as child of OBJ and if :AUTO-PLACE place-inside-bottom-of OBJ."
|
||||
"Create a new clog-obj from HTML element as child of OBJ and if :AUTO-PLACE
|
||||
place-inside-bottom-of OBJ."
|
||||
(let ((child (create-with-html (connection-id obj) html)))
|
||||
(if auto-place
|
||||
(place-inside-bottom-of obj child)
|
||||
child)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
;; attach-as-child ;;
|
||||
;;;;;;;;;;;;;;;;;;;;;
|
||||
|
||||
(export 'attach-as-child)
|
||||
(defmethod attach-as-child ((obj clog-obj) html-id)
|
||||
"Create a new clog-obj and attach an existing element with HTML-ID. The
|
||||
HTML-ID must be unique."
|
||||
(cc:execute (connection-id obj) (format nil "clog['~A']=$('#~A')" html-id html-id))
|
||||
(make-instance 'clog-obj :connection-id (connection-id obj) :html-id html-id))
|
||||
|
||||
;;;;;;;;;;;;;;;;;
|
||||
;; place-after ;;
|
||||
;;;;;;;;;;;;;;;;;
|
||||
|
|
@ -167,7 +180,7 @@ lisp and the HTML DOM element."))
|
|||
(defun on-connect (id)
|
||||
(when cc:*verbose-output*
|
||||
(format t "Start new window handler on connection-id - ~A" id))
|
||||
(let ((body (attach id 0)))
|
||||
(let ((body (make-instance 'clog-obj :connection-id id :html-id 0)))
|
||||
(funcall *on-new-window* body)))
|
||||
|
||||
(defun initialize (on-new-window
|
||||
|
|
@ -202,6 +215,7 @@ located at STATIC-ROOT."
|
|||
(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."
|
||||
(cc:execute connection-id (format nil "clog['~A']=$('#~A')" html-id html-id))
|
||||
(make-instance 'clog-obj :connection-id connection-id :html-id html-id))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;;;;;
|
||||
|
|
@ -215,9 +229,9 @@ requires placement or will not be visible, ie. place-after, etc"
|
|||
(let ((web-id (cc:generate-id)))
|
||||
(cc:execute
|
||||
connection-id
|
||||
(format nil "clog['~A']=$(\"~A\"); clog['~A'].first().prop('id','~A');"
|
||||
(format nil "clog['~A']=$(\"~A\"); clog['~A'].first().prop('id','~A')"
|
||||
web-id html web-id web-id))
|
||||
(attach connection-id web-id)))
|
||||
(make-instance 'clog-obj :connection-id connection-id :html-id web-id)))
|
||||
|
||||
;;;;;;;;;;;;;;;;;;
|
||||
;; open-browser ;;
|
||||
|
|
|
|||
|
|
@ -7,13 +7,16 @@
|
|||
(defvar *last-obj*)
|
||||
|
||||
(defun on-new-window (win)
|
||||
(create-child win "<button>test</botton>")
|
||||
(create-child win "<H2>Cool!</H2>")
|
||||
(setf *last-obj* (create-child win "<button>a</button>")))
|
||||
(let ((tmp))
|
||||
(clog-connection:put-line (clog::connection-id win) "<button id='myid'>In html</button>")
|
||||
(setf tmp (attach-as-child win "myid"))
|
||||
(clog::jquery-execute tmp "css('background-color','red')")
|
||||
(create-child win "<button>test</botton>")
|
||||
(create-child win "<H2>Cool!</H2>")
|
||||
(setf *last-obj* (create-child win "<button>a</button>"))))
|
||||
|
||||
(defun test ()
|
||||
(print "Init connection")
|
||||
(initialize #'on-new-window :boot-file "/debug.html")
|
||||
(print "Connection set")
|
||||
(print "Open browser")
|
||||
(open-browser))
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue