Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Added on_update #1

Merged
merged 1 commit into from over 2 years ago

2 participants

Owen Gunden Adam Koprowski
Owen Gunden

No description provided.

Adam Koprowski akoprow merged commit 5cdc95a into from
Adam Koprowski akoprow closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Showing 1 unique commit by 1 author.

Mar 01, 2012
Owen Gunden ogunden Add on_update and associated demo. 255bdfd
This page is out of date. Refresh to see the latest.
31 jquery-ui-demo.opa
@@ -9,6 +9,7 @@ module Sortable {
9 9 { name: "Sortable"
10 10 , pages:
11 11 [ {name: "Default functionality", show: default_functionality }
  12 + ,{name: "on_update" , show: on_update_demo }
12 13 ]
13 14 }
14 15
@@ -20,9 +21,33 @@ module Sortable {
20 21 jQueryUI.Sortable.mk_sortable(#sortable)
21 22 jQueryUI.Sortable.disable_selection(#sortable)
22 23 }
23   - <ul id=sortable onready={mk_sortable}>
24   - {List.init(mk_entry, 7)}
25   - </ul>
  24 + <div>
  25 + <ul id=sortable onready={mk_sortable}>
  26 + {List.init(mk_entry, 7)}
  27 + </ul>
  28 + </div>
  29 + }
  30 +
  31 + client function on_update_demo() {
  32 + function mk_entry(i) {
  33 + <li id={i}><div class="alert alert-info">Item #{i}</></>
  34 + }
  35 + function on_update() {
  36 + children = Dom.split(Dom.select_children(#sortable))
  37 + l = List.map( function(d) { Dom.get_id(d) }, children)
  38 + #sorting = "sorting is: " ^ String.concat(", ", l)
  39 + }
  40 + function mk_sortable(_) {
  41 + jQueryUI.Sortable.mk_sortable(#sortable)
  42 + jQueryUI.Sortable.disable_selection(#sortable)
  43 + jQueryUI.Sortable.on_update(#sortable, on_update)
  44 + }
  45 + <div>
  46 + <span id=sorting/>
  47 + <ul id=sortable onready={mk_sortable}>
  48 + {List.init(mk_entry, 7)}
  49 + </ul>
  50 + </div>
26 51 }
27 52
28 53 }
5 packages/jQueryUI/jQueryUI.opa
@@ -14,6 +14,11 @@ module jQueryUI {
14 14 %%JQueryUI.disable_selection%%(elt)
15 15 }
16 16
  17 + function void on_update(dom, f) {
  18 + elt = Dom.of_selection(dom)
  19 + %%JQueryUI.sortable_on_update%%(elt,f)
  20 + }
  21 +
17 22 }
18 23
19 24 }
7 packages/jQueryUI/jQueryUI/jQueryUI.js
@@ -13,3 +13,10 @@
13 13 dom.disableSelection();
14 14 return js_void;
15 15 }
  16 +
  17 +##register sortable_on_update : Dom.private.element, ( -> void) -> void
  18 +##args(dom, on_update)
  19 +{
  20 +return dom.bind( "sortupdate", function(event, ui) { on_update(); } );
  21 +}
  22 +

Tip: You can add notes to lines in a file. Hover to the left of a line to make a note

Something went wrong with that request. Please try again.