Tag Archives: jquery

How to write jQuery plugins in Haxe

This blog post recorded how I came up with the idea. You may jump to the GitHub repo directly, example usage is written there.

Everthing started from an old jQuery plugin

Recently I started to use Haxe as my primary programming language. I have always been thinking about what I can do with this modern language. Until I dug out an old jQuery plugin, which I wrote several years ago, while I was cleaning up some old files in my server. I remembered that it wasn’t easy to develop in javascript. It is because at that time there was no (or at least I was not aware of any) decent IDE for javascript. Even with the powerful debugger FireBug, which just began to gain popularity at that time, I still found it painful to debug javascript programs. Therefore I have stopped writing in javascript since then. Looking at the plugin’s forgotten to-do list and the unfinished next-version, I decided to find a way writing jQuery plugins (again) in Haxe.

Here is my goal to be done in Haxe:

  1. Register a function as a jQuery plugin by adding it to the jQuery.fn object
  2. Able to access the “this” object within the plugin function as in vanilla javascript
  3. The javascript output should be as simple and clean as possible
  4. Most important: Leverage Haxe’s feature such as Macros, Code-Completion, Compiler Checks to write a decent plugin

Continue reading How to write jQuery plugins in Haxe