Skip to content

Instantly share code, notes, and snippets.

@padolsey
Created November 21, 2009 12:42
Show Gist options
  • Select an option

  • Save padolsey/240115 to your computer and use it in GitHub Desktop.

Select an option

Save padolsey/240115 to your computer and use it in GitHub Desktop.
jQuery(yourNodes).append(jQuery('<a>Click</a>').click(function(){
var self = this.parentNode, // parentNode is a single element within yourNodes
loading = $('<div>LOADING</div>').appendTo(self),
id = self.id.replace(/^edit/,'');
// Retrieve textarea from server
jQuery.get('/getDataForTextArea?id=' + id, function(textareaValue){
loading.remove();
var textarea = jQuery('<textarea/>')
.attr('id', 'txt' + id)
.val(textareaValue)
.add(
jQuery('<button>Save</button>')
.attr('id', 'btnSave' + id)
.click(function(){ /* Click handler */ })
)
.add(
jQuery('<button>Cancel</button>')
.attr('id', 'btnCancel' + id)
.click(function(){
/* Remove nodes */
tr.remove();
})
);
var tr = jQuery('<tr colspan="4"><td/></tr>');
tr.find('td').append(textarea);
tr.appendTo(self);
});
}));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment