jQuery extern for haXe
Haxe JavaScript
Pull request Compare This branch is 3 commits ahead, 115 commits behind andyli:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
jQuery
test
.gitignore
.paths
.project
JQuery.hx
README.md
compile.hxml
distribute-0.6.28.tar.gz
haxelib.xml
jQueryExternForHaxe.hxproj

README.md

jQueryExtern

jQuery extern for haXe.

Currently support jQuery version 1.7.2. Experimental jQuery 1.8 support can be enabled with -D JQUERY1_8.

You may check my blog for updates.

Download and Install

Install via haxelib: haxelib install jQueryExtern

Then put -lib jQueryExtern into your hxml.

Or you can manually download and then place the folder jQuery into your project source folder.

Usage

Typically:

import jQuery.JQuery;

class Main {
    static public function main():Void {
        new JQuery(function():Void { //when document is ready
            //your magic
        });
    }
}

It is same as how you use jQuery in JS. But instead of $, you refer jQuery as JQuery.

eg. Hiding all li object:

new JQuery("li").hide(); //same as $("li").hide() in JS

Static methods of jQuery can be accessed from JQuery._static or from JQueryStatic.

eg. A ajax example:

JQuery._static.get("ajax/test.html", function(data) {
    js.Lib.alert(data);
});

Remember jQueryExtern is simply an extern, you have to link jQuery in your html file.

eg. In your <head>:

<!-- jQuery from Google CDN -->
<script type="text/javascript" src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.7.1.min.js"></script>

<!-- Your haxe compiled script: -->
<script type="text/javascript" src="Main.js"></script>

js.JQuery in haxe std lib VS jQueryExtern

js.JQuery jQueryExtern
import statement "import js.JQuery;" "import jQuery.JQuery;"
jQuery API version partial 1.6.4 complete 1.7.1
refer jQuery in output as "js.JQuery" "$" (or "jQuery" if -D JQUERY_NOCONFLICT)
include jQuery in output yes (can be opt-out by -D noEmbedJS) no, use CDN instead

License

jQueryExtern is released in the public domain. NO WARRANTY EXPRESSED OR IMPLIED. USE AT YOUR OWN RISK.

jQuery's license can be found at http://jquery.org/license.