mirror of
https://github.com/rabbibotton/clog.git
synced 2025-12-06 02:30:42 -08:00
list-of-children
This commit is contained in:
parent
452ee0b1b8
commit
0287d16884
2 changed files with 35 additions and 1 deletions
|
|
@ -2379,6 +2379,39 @@ used for DOM tree walking or other throw away purposes."))
|
||||||
(defmethod parent-element ((obj clog-element))
|
(defmethod parent-element ((obj clog-element))
|
||||||
(attach-as-child obj (jquery-query obj (format nil "parent().prop('id')"))))
|
(attach-as-child obj (jquery-query obj (format nil "parent().prop('id')"))))
|
||||||
|
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
;; list-of-children ;;
|
||||||
|
;;;;;;;;;;;;;;;;;;;;;;
|
||||||
|
|
||||||
|
(defgeneric list-of-children (clog-element &key no-attach)
|
||||||
|
(:documentation "Returns a list of child clog-element objects. If no-attach
|
||||||
|
is t they are only functional if there previously was an attach or was created
|
||||||
|
by CLOG, i.e. if just walking the DOM of existing clog-objects these are
|
||||||
|
like pointers."))
|
||||||
|
|
||||||
|
(defmethod list-of-children ((obj clog-element) &key no-attach)
|
||||||
|
(let ((result (read-from-string (js-query obj (format nil
|
||||||
|
"const tmpf=function(obj) {
|
||||||
|
var tmp='(' + obj.prop('id');
|
||||||
|
obj.children().each(function() {
|
||||||
|
if ( $(this).children().first() ) {
|
||||||
|
tmp=tmp + tmpf( $(this) );
|
||||||
|
} else {
|
||||||
|
tmp=tmp + $(this).prop('id') + ' '; } } );
|
||||||
|
return tmp+')';}
|
||||||
|
tmpf(~A);"
|
||||||
|
(jquery obj))))))
|
||||||
|
(labels ((tr (item)
|
||||||
|
(if no-attach
|
||||||
|
(make-clog-element (connection-id obj) item :clog-type 'clog-element)
|
||||||
|
(attach-as-child obj item)))
|
||||||
|
(ll (lst)
|
||||||
|
(mapcar (lambda (l)
|
||||||
|
(if (listp l)
|
||||||
|
(ll l)
|
||||||
|
(tr l)))
|
||||||
|
lst)))
|
||||||
|
(rest (ll result)))))
|
||||||
|
|
||||||
;;;;;;;;;;;;;;;;;
|
;;;;;;;;;;;;;;;;;
|
||||||
;; first-child ;;
|
;; first-child ;;
|
||||||
|
|
|
||||||
|
|
@ -393,7 +393,8 @@ embedded in a native template application.)"
|
||||||
(parent-element generic-function)
|
(parent-element generic-function)
|
||||||
(first-child generic-function)
|
(first-child generic-function)
|
||||||
(previous-sibling generic-function)
|
(previous-sibling generic-function)
|
||||||
(next-sibling generic-function))
|
(next-sibling generic-function)
|
||||||
|
(list-of-children generic-function))
|
||||||
|
|
||||||
(defsection @clog-jquery (:title "CLOG jQuery Objects")
|
(defsection @clog-jquery (:title "CLOG jQuery Objects")
|
||||||
"CLOG-jQuery - Base class for CLOG jQuery Objects"
|
"CLOG-jQuery - Base class for CLOG jQuery Objects"
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue