Permalink
Browse files

Merge pull request #1 from ogunden/master

Added on_update
  • Loading branch information...
2 parents f5ce475 + 255bdfd commit 5cdc95afdd42bae9d977e423250725b393a51bf7 @akoprow akoprow committed Mar 3, 2012
Showing with 40 additions and 3 deletions.
  1. +28 −3 jquery-ui-demo.opa
  2. +5 −0 packages/jQueryUI/jQueryUI.opa
  3. +7 −0 packages/jQueryUI/jQueryUI/jQueryUI.js
View
@@ -9,6 +9,7 @@ module Sortable {
{ name: "Sortable"
, pages:
[ {name: "Default functionality", show: default_functionality }
+ ,{name: "on_update" , show: on_update_demo }
]
}
@@ -20,9 +21,33 @@ module Sortable {
jQueryUI.Sortable.mk_sortable(#sortable)
jQueryUI.Sortable.disable_selection(#sortable)
}
- <ul id=sortable onready={mk_sortable}>
- {List.init(mk_entry, 7)}
- </ul>
+ <div>
+ <ul id=sortable onready={mk_sortable}>
+ {List.init(mk_entry, 7)}
+ </ul>
+ </div>
+ }
+
+ client function on_update_demo() {
+ function mk_entry(i) {
+ <li id={i}><div class="alert alert-info">Item #{i}</></>
+ }
+ function on_update() {
+ children = Dom.split(Dom.select_children(#sortable))
+ l = List.map( function(d) { Dom.get_id(d) }, children)
+ #sorting = "sorting is: " ^ String.concat(", ", l)
+ }
+ function mk_sortable(_) {
+ jQueryUI.Sortable.mk_sortable(#sortable)
+ jQueryUI.Sortable.disable_selection(#sortable)
+ jQueryUI.Sortable.on_update(#sortable, on_update)
+ }
+ <div>
+ <span id=sorting/>
+ <ul id=sortable onready={mk_sortable}>
+ {List.init(mk_entry, 7)}
+ </ul>
+ </div>
}
}
@@ -14,6 +14,11 @@ module jQueryUI {
%%JQueryUI.disable_selection%%(elt)
}
+ function void on_update(dom, f) {
+ elt = Dom.of_selection(dom)
+ %%JQueryUI.sortable_on_update%%(elt,f)
+ }
+
}
}
@@ -13,3 +13,10 @@
dom.disableSelection();
return js_void;
}
+
+##register sortable_on_update : Dom.private.element, ( -> void) -> void
+##args(dom, on_update)
+{
+return dom.bind( "sortupdate", function(event, ui) { on_update(); } );
+}
+

0 comments on commit 5cdc95a

Please sign in to comment.