Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function isRowEmpty(){
- var emptyRow = true;
- var tableRow;
- $('#ProblemsGrid').delegate('td a', 'click', function() {
- tableRow = $(this).closest ('tr');
- });
- tableRow.find('textarea').each(function(index, element){
- var value = $(element).val();
- if(value != "") {emptyRow = false;}
- });
- return emptyRow;
- }
- function deleteRow(){
- if (isRowEmpty()===true){
- $('#ProblemsGrid').delegate('td a', 'click', function() {
- $(this).closest ('tr').remove();
- });
- }
- }
- <tr>
- <td><textarea name='text' style='width: 98%; height:40px'>....</textarea></td>
- <td><a href='#anchor' name='DeleteButton' onclick='deleteRow();'>
- <img src='../images/delete.gif'></img> </a>
- </td>
- </tr>
- $('.deleteRow').on('click', function() {
- var tr = $(this).closest('tr');
- var remove = true;
- tr.find('textarea').each(function() {
- if ($(this).val() != '') {
- remove = false;
- }
- });
- if (remove) {
- tr.remove();
- }
- });
- $(document).on('click', '.deleteRow', function() {
- // ...
- });
- function deleteRow(){
- if (emptyRow){// isRowEmpty returning emptyRow
- $('#ProblemsGrid').delegate('td a', 'click', function() {
- $(this).closest ('tr').remove();
- });
- }
- }
- function isRowEmpty(el){
- var emptyRow = true;
- if(el.val() != "" && el.val() != "....")
- emptyRow = false;
- return emptyRow;
- }
- $(document).delegate('#ProblemsGrid td a', 'click', function() {
- if (isRowEmpty($(this).closest('tr').find('textarea'))){
- $(this).closest('tr').remove();
- }
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement