Javascript inline function parser

Since the dawn of time I’ve needed method to put a Javascript code into HTML node in a nice manner. Finally it’s here! I shall present to you inline function parser for JS callbacks…

The idea is fairly simple. You build your callback library, when something happens on a node, then it fires a list of callbacks with some specific arguments.

Declaration of callbacks looks like this:

<div data-callback="firstCallback('arg1', ..., 'argN'); secondCallback('arg1')"></div>

Now you can do some operation on such node and after it finishes fire a series of declared callbacks. Please check JSFiddle example below:

Maybe I’ll wrap this in some kind of nice library and put it on Github. Anyone interested? Fell free to comment.



Posted

in