Guest User

Untitled

a guest
Jul 18th, 2018
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. var sortableData = function (data)
  2. {
  3. var that = {},
  4. _super,
  5. _data;
  6.  
  7. // PRIVATE METHODS
  8. // ################################################
  9.  
  10. function _onChange(newData)
  11. {
  12. _data = newData + ' sorted';
  13. return _data;
  14. }
  15.  
  16. // PUBLIC
  17. // ################################################
  18.  
  19. that.set = function(x)
  20. {
  21. // set our simpleData, if it changes our onChange will finish it off
  22. _super.set(x);
  23. }
  24.  
  25. that.get = function()
  26. {
  27. return _data;
  28. }
  29.  
  30. // INIT
  31. // ################################################
  32.  
  33. // always keep a simpleData instance
  34. _super = simpleData(data);
  35.  
  36. // when the simpleData instance changes we process it and store it
  37. _data = _onChange(_super.get());
  38.  
  39. // re-process our data whenever the simpleData instance changes
  40. $(_super).bind('change', function()
  41. {
  42. _onChange(_super.get());
  43. });
  44.  
  45. return that;
  46. }
Add Comment
Please, Sign In to add comment