Guest User

Untitled

a guest
Jan 19th, 2019
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.23 KB | None | 0 0
  1. function User( username, date_inactive, date_active ) {
  2. this.username = username;
  3. this.date_active = date_active;
  4. this.date_inactive = date_inactive;
  5. };
  6.  
  7. User.prototype.inactivateMe = function() {
  8. json_responses.push( this );
  9. $.getJSON( "url" + this.username, function( json ) {
  10. original = json_response.pop();
  11. //do update here
  12. });
  13. };
  14.  
  15. userModel = [ ], //Where the loaded usernames are stored.
  16.  
  17. viewUserModel = {
  18. users: ko.observableArray(userModel)
  19. //.......
  20.  
  21. //This is how I'm adding users to the array.
  22. addUser: function () {
  23. $.getJSON( "url",
  24. { username: usern },
  25. function( json ) {
  26. if( json.STATUS != undefined && json.STATUS == 'success' ) {
  27. newuser = new User( json.USERNAME, json.DATE_ACTIVE, json.DATE_INACTIVE );
  28. viewUserModel.users.push( newuser );
  29. }
  30. }
  31. });
  32. }
  33.  
  34. function User( username, date_inactive, date_active ) {
  35. this.username = username;
  36. this.date_active = ko.observable(date_active);
  37. this.date_inactive = ko.observable(date_inactive);
  38. };
  39.  
  40. <div data-bind="foreach: Users">
  41. <input data-bind="value: date_active"/>
  42. <input data-bind="value: date_inactive"/>
  43. <div>​
Add Comment
Please, Sign In to add comment