Hi,
I am experimenting with clojurescript, and have the following page -
(ns maze.views.mm
(:use [noir.core :only [defpartial]]
[hiccup.page :only [html5 include-js]]
[hiccup.element :only [javascript-tag]]
[maze.views.cssgenerator]
[maze.constants]))
(defn generate-options []
(map #(html5 [:option {:value %1} %2]) (range 0 4) difficulty-levels))
;; Creates the main html layout
(defpartial generate-layout
[params title & content]
(html5
[:head [:title title]
[:meta {:charset "UTF-8"}]
[:style {:type "text/css"} (global-css params)]
(include-js
"https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js")]
[:body {:bgcolor "#FFFFFF"}
[:table {:cellpading 20 :cellspacing 0 :width "100%" :border 0}
[:tr
[:td {:width "70%" :align "center"}
[:div#mazediv]]
[:td {:width "30%" :align "center" :valign "top"}
[:h1 "Mysterious"
[:br "Maze"]]
[:small directions]
[:p]
[:div#scorediv {:style "background-color: grey;color: yellow"}
"SCORE : 0"]
[:p]
[:div#statdiv {:style "background-color: grey;color: yellow"}
"WAITING..."]
[:p]
[:select#level
(generate-options)]
[:p]
[:input#start {:type :button :value "Start New Game"}]]]]
[:div.copy
"Copyright © 2012 Manoj Waikar. All Rights Reserved."]
(javascript-tag "var CLOSURE_NO_DEPS = true;")
(include-js "/cljs/main.js")]))
and this is in my main.cljs file -
(ns maze.main
(:use [jayq.core :only [$]]))
;; frequently used selectors
(def $start ($ :#start))
(def $statdiv ($ :#statdiv))
(def $scorediv ($ :#scorediv))
(defn start-game []
())
(.click ($ :#start
(fn [e]
(println "hey")
(js/alert "clicked"))))
Here's my project.clj (just in case) -
(defproject maze "0.1.0-SNAPSHOT"
:description "FIXME: write description"
:url "http://example.com/FIXME"
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.4.0"]
[hiccup "1.0.0"]
[noir "1.3.0-beta10"]
[cssgen "0.2.6"]
[jayq "0.1.0-alpha4"]]
:plugins [[lein-cljsbuild "0.1.10"]]
:hooks [leiningen.cljsbuild]
:jvm-opts ["-Dfile.encoding=utf-8"]
:cljsbuild
{:builds
[{:source-path "src-cljs",
:compiler
{:output-dir "resources/public/cljs/",
:output-to "resources/public/cljs/main.js",
:optimizations :whitespace,
:pretty-print true}}]}
:main maze.server)
The problem is that the click event of the start button is not getting
properly registered.
Please let me know what is the problem.
Thanks,
Manoj.
--
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to [email protected]
Note that posts from new members are moderated - please be patient with your
first post.
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en