Skip to content

Instantly share code, notes, and snippets.

Created December 16, 2011 18:00
Show Gist options
  • Save anonymous/1487157 to your computer and use it in GitHub Desktop.
Save anonymous/1487157 to your computer and use it in GitHub Desktop.
clojuresrcipt question
(ns simplebutton.core
(:require [goog.dom :as dom]))
;; -------------------------= Debug =-----------------------
(defn debug
"Output goes to your web browser's console"
[msg]
(js/console.log msg))
;(defn debug [_]) ;; switch to this debug to turn off output
(defn ^:export copytext []
(debug "in the copytext code")
(debug (.value (dom/getElement "field1")))
(let [e (dom/getElement "field2")]
(doto e (dom/setTextContent (.value (dom/getElement "field1")))))
)
<html>
<head>
<title>Simple Button</title>
</head>
<body>
<script type="text/javascript" src="out/goog/base.js"></script>
<script type="text/javascript" src="simplebutton.js"></script>
<script>
goog.require('simplebutton.core');
</script>
Field1: <input type="text" id="field1" value="Hello World!" />
<br />
Field2: <input type="text" id="field2" />
<br /><br />
Click the button to copy the content of Field1 to Field2.
<br />
<button onclick="simplebutton.core.copytext();">Copy Text</button>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment