Advertisement
Guest User

Untitled

a guest
Apr 20th, 2014
55
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.71 KB | None | 0 0
  1. function isRowEmpty(){
  2. var emptyRow = true;
  3. var tableRow;
  4. $('#ProblemsGrid').delegate('td a', 'click', function() {
  5. tableRow = $(this).closest ('tr');
  6. });
  7.  
  8. tableRow.find('textarea').each(function(index, element){
  9. var value = $(element).val();
  10. if(value != "") {emptyRow = false;}
  11. });
  12. return emptyRow;
  13. }
  14.  
  15. function deleteRow(){
  16. if (isRowEmpty()===true){
  17. $('#ProblemsGrid').delegate('td a', 'click', function() {
  18. $(this).closest ('tr').remove();
  19. });
  20. }
  21. }
  22.  
  23. <tr>
  24. <td><textarea name='text' style='width: 98%; height:40px'>....</textarea></td>
  25. <td><a href='#anchor' name='DeleteButton' onclick='deleteRow();'>
  26. <img src='../images/delete.gif'></img> </a>
  27. </td>
  28. </tr>
  29.  
  30. $('.deleteRow').on('click', function() {
  31. var tr = $(this).closest('tr');
  32. var remove = true;
  33. tr.find('textarea').each(function() {
  34. if ($(this).val() != '') {
  35. remove = false;
  36. }
  37. });
  38. if (remove) {
  39. tr.remove();
  40. }
  41. });
  42.  
  43. $(document).on('click', '.deleteRow', function() {
  44. // ...
  45. });
  46.  
  47. function deleteRow(){
  48. if (emptyRow){// isRowEmpty returning emptyRow
  49. $('#ProblemsGrid').delegate('td a', 'click', function() {
  50. $(this).closest ('tr').remove();
  51. });
  52. }
  53. }
  54.  
  55. function isRowEmpty(el){
  56. var emptyRow = true;
  57. if(el.val() != "" && el.val() != "....")
  58. emptyRow = false;
  59. return emptyRow;
  60. }
  61.  
  62. $(document).delegate('#ProblemsGrid td a', 'click', function() {
  63. if (isRowEmpty($(this).closest('tr').find('textarea'))){
  64. $(this).closest('tr').remove();
  65. }
  66. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement