Guest User

Untitled

a guest
Apr 24th, 2018
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.08 KB | None | 0 0
  1. jQuery(yourNodes).append(jQuery('<a>Click</a>').click(function(){
  2.  
  3. var self = this.parentNode, // parentNode is a single element within yourNodes
  4. loading = $('<div>LOADING</div>').appendTo(self),
  5. id = self.id.replace(/^edit/,'');
  6.  
  7. // Retrieve textarea from server
  8. jQuery.get('/getDataForTextArea?id=' + id, function(textareaValue){
  9.  
  10. loading.remove();
  11.  
  12. var textarea = jQuery('<textarea/>')
  13. .attr('id', 'txt' + id)
  14. .val(textareaValue)
  15. .add(
  16. jQuery('<button>Save</button>')
  17. .attr('id', 'btnSave' + id)
  18. .click(function(){ /* Click handler */ })
  19. )
  20. .add(
  21. jQuery('<button>Cancel</button>')
  22. .attr('id', 'btnCancel' + id)
  23. .click(function(){
  24. /* Remove nodes */
  25. tr.remove();
  26. })
  27. );
  28.  
  29. var tr = jQuery('<tr colspan="4"><td/></tr>');
  30.  
  31. tr.find('td').append(textarea);
  32. tr.appendTo(self);
  33.  
  34. });
  35.  
  36. }));
Add Comment
Please, Sign In to add comment