Guest User

Untitled

a guest
May 27th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. var Driver = {
  2. add: function(event) {
  3. event.stop();
  4.  
  5. $(this.get('rel'))
  6. .insert(Driver.template(this))
  7. .subNodes().last().show('fade');
  8. },
  9.  
  10. remove: function(event) {
  11. event.stop();
  12.  
  13. var item = this.parent('.item');
  14. var link = item.first('a.delete');
  15. var options = {};
  16.  
  17. if (link) {
  18. link.first('input').value = 1;
  19. } else {
  20. options.onFinish = item.remove.bind(item);
  21. }
  22.  
  23. item.hide('fade', options);
  24. },
  25.  
  26. template: function(element) {
  27. return window[element.parent('.nested').get('data-template')]
  28. .replace(/NEW_RECORD/g, new Date().getTime());
  29. }
  30. };
  31.  
  32. ".nested .add_nested".on('click', Driver.add);
  33. ".nested .remove_nested".on('click', Driver.remove);
Add Comment
Please, Sign In to add comment