Skip to content

Instantly share code, notes, and snippets.

@zippy
Created October 11, 2011 00:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zippy/1276936 to your computer and use it in GitHub Desktop.
Save zippy/1276936 to your computer and use it in GitHub Desktop.
clojurescript and goog.ui.select
(defn make-select [elem-id]
(let [select (goog.ui.Select. "Heading")
select-elem (d/element (keyword (str "div#" elem-id)))]
(.addItemAt select (goog.ui.MenuItem. "Item 1") 0)
(.addItem select (goog.ui.Option. "Item 2"))
(.render select select-elem)
select-elem
)
)
;; when you add the results of a calling the above function with:
(make-select :channel)
;; to the dom, it produces:
<div id="channel"><div class="goog-inline-block goog-menu-button" title="" role="button" style="-webkit-user-select: none; " tabindex="0" aria-haspopup="true" aria-pressed="false" aria-expanded="false" aria-activedescendant=""><div class="goog-inline-block goog-menu-button-outer-box"><div class="goog-inline-block goog-menu-button-inner-box"><div class="goog-inline-block goog-menu-button-caption">Heading</div><div class="goog-inline-block goog-menu-button-dropdown">&nbsp;</div></div></div></div></div>
;; So, where are the Items?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment