[Opa] jquery-ui: Sortable

Owen Gunden ogunden at phauna.org
Thu Feb 16 22:44:42 UTC 2012


I posted this as a comment on this blog post:

  http://blog.opalang.org/2012/01/reusing-javascript-libraries-jquery-ui.html

I thought I'd repost here in hopes of getting attention sooner :)

-----------

Hi Adam,

I am trying to get something similar working with jquery-ui's
Sortable. I've downloaded the custom bundle, and put together a stub
js file.

% cat contrib/jquery-ui/juistubs.js
##extern-type dom_element

##register mk_sortable : dom_element -> dom_element
##args(dom)
{
return dom.sortable({});
}

##register sortable_on_update : dom_element, ( -> void) -> void
##args(dom, on_update)
{
return dom.bind( "sortupdate", function(event, ui) { on_update(); } );
}

% cat sortable.opa
@client mk_sortable = %%juistubs.mk_sortable%%
@client sortable_on_update = %%juistubs.sortable_on_update%%

Sortable = {{
//TODO: abstract type?
init(dom) = mk_sortable(Dom.of_selection(dom))

register_on_update(dom,f) = sortable_on_update(Dom.of_selection(dom),f)
}}

I compile with:

% opa-plugin-builder --js-validator-off
contrib/jquery-ui/js/jquery-ui-1.8.17.custom.min.js
contrib/jquery-ui/juistubs.js -o jui.opp

and then

% opa --parser classic sortable.opa ... jui.opp


The result is when I navigate to my site, the following javascript
console error messages:

Uncaught SyntaxError: Undefined label 'droppablesLoop' (all.js: 29572)
Uncaught ReferenceError: $ is not defined



I tried also adding contrib/jquery-ui/js/jquery-1.7.1.min.js into the
plugin, but I get the same error (though it's in a different part of
all.js).

Have I overlooked something simple?


More information about the Opa mailing list