Skip to content
Browse files

Merge branch 'master' of github.com:ibdknox/jayq

Conflicts:
	src/jayq/core.cljs
  • Loading branch information...
2 parents ea04ab8 + b9defce commit a0f35a424a77b460b409cb0579c69807f135d812 @ibdknox committed May 9, 2012
Showing with 46 additions and 3 deletions.
  1. +15 −0 README.md
  2. +1 −1 project.clj
  3. +30 −2 src/jayq/core.cljs
View
15 README.md
@@ -54,6 +54,21 @@ for us to build exactly that.
```
+## Compiling
+
+If you're using advanced Clojurescript compilation you'll need to reference the jquery externs file. Add this to your compilation options:
+
+```clojure
+
+ {
+ :optimizations :advanced
+ :externs ["externs/jquery.js"]
+ ...
+ }
+```
+
+Without this, you'l see errors like 'Object ... has no method XX'. See http://lukevanderhart.com/2011/09/30/using-javascript-and-clojurescript.html for more on externs.
+
## License
Copyright (C) 2011 Chris Granger
View
2 project.clj
@@ -1,3 +1,3 @@
-(defproject jayq "0.1.0-alpha3"
+(defproject jayq "0.1.0-alpha4"
:description "A ClojureScript wrapper for jQuery"
:dependencies [[clojure "1.3.0"]])
View
32 src/jayq/core.cljs
@@ -55,9 +55,9 @@
IReduce
(-reduce [this f]
- (ci-reduce coll f (first this) (count this)))
+ (ci-reduce this f))
(-reduce [this f start]
- (ci-reduce coll f start i)))
+ (ci-reduce this f start)))
(set! jQuery.prototype.call
(fn
@@ -81,6 +81,9 @@
(. $elem (attr a))
(. $elem (attr a v)))))
+(defn remove-attr [$elem a]
+ (.removeAttr $elem (name a)))
+
(defn data [$elem k & [v]]
(let [k (name k)]
(if-not v
@@ -102,6 +105,16 @@
(let [cl (name cl)]
(.toggleClass $elem cl)))
+(defn has-class [$elem cl]
+ (let [cl (name cl)]
+ (.hasClass $elem cl)))
+
+(defn after [$elem content]
+ (.after $elem content))
+
+(defn before [$elem content]
+ (.before $elem content))
+
(defn append [$elem content]
(.append $elem content))
@@ -138,6 +151,9 @@
(defn find [$elem selector]
(.find $elem (name selector)))
+(defn closest [$elem selector & [context]]
+ (.closest $elem selector context))
+
(defn clone [$elem]
(.clone $elem))
@@ -152,6 +168,9 @@
(.val $elem v)
(. $elem (val))))
+(defn serialize [$elem]
+ (.serialize $elem))
+
(defn queue [$elem callback]
(. $elem (queue callback)))
@@ -167,13 +186,22 @@
:success callback})]
(.ajax js/jQuery uri params)))
+(defn ajax
+ ([url settings]
+ (.ajax js/jQuery url (clj->js settings)))
+ ([settings]
+ (.ajax js/jQuery (clj->js settings))))
+
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; Events
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defn bind [$elem ev func]
(.bind $elem (name ev) func))
+(defn unbind [$elem ev & [func]]
+ (.unbind $elem (name ev) func))
+
(defn trigger [$elem ev]
(.trigger $elem (name ev)))

0 comments on commit a0f35a4

Please sign in to comment.
Something went wrong with that request. Please try again.