dracoblue.net

Jsb 2.0.0 released

I finally released a new major version of jsb.

With 2.0 there are two breaking changes (you might still use 1.x series, if you rely on those.

  1. The global JsBehaviourToolkit got removed #20.
  2. A input[hidden] cannot be used as data source anymore #17.

That's it.

But jsb 2.0 comes with some cool additions.

Jsb registers itself as requirejs module called jsb #18, the github repository is called jsb and the bower module name is jsb #13, too.

It's also possible to define multiple behaviours #16 on one element: class="jsb_ jsb_Example jsb_ExampleTwo" and to define behaviour specific data with data-jsb-Example instead of the fallback data-jsb #16.

The readme has been polished to reflect how you use jsb with bower and requirejs and how to force a dependency from jsb to jquery (even though jsb works very fine without jquery).

Since 1.7 the behaviours had a nice requirejs integration and with those changes it becomes even more helpful. This is all code to define a new js behaviour in your existing requirejs + jsb enhanced website:

/* js/Example.js */
define("Example", [], function()
{
    "use strict";

    var Example = function(dom_element, options) {
       dom_element.textContent = 'I am loaded with name: ' + options.name;
    };

    return Example;
});

And somewhere in your HTML (data-jsb takes the parameters as query string):

<span class="jsb_ jsb_Example" data-jsb="name=Jan&amp;param1=one">Are you loaded?</span>

If you generate the code with a dynamic language you might use a json object as data-jsb content (and you might be explicit with data-jsb-Example):

<span class="jsb_ jsb_Example" data-jsb-Example="{&quot;name&quot;:&quot;Jan&quot;}" >Are you loaded?</span>

Thanks to everyone contributing to jsb (with comments and issues on github) and of course to everyone using jsb in production!

In javascript, jquery, jsb, mootools, open source by
@ 18 May 2014, Comments at Reddit & Hackernews

Give something back

Were my blog posts useful to you? If you want to give back, support one of these charities, too!

Report hate in social media Campact e.V. With our technology and your help, we protect the oceans from plastic waste. Gesellschaft fur Freiheitsrechte e. V. The civil eye in the mediterranean

Recent Dev-Articles

Read recently

Recent Files

About