Skip to content

Instantly share code, notes, and snippets.

@thinkt4nk
Created February 25, 2011 15:13
Show Gist options
  • Save thinkt4nk/843920 to your computer and use it in GitHub Desktop.
Save thinkt4nk/843920 to your computer and use it in GitHub Desktop.
mto inputs
$(document).ready(function() {
// initial input addition
$(".forum_thumbnail_addThumbnail").live('click',function() {
var $this = $(this);
$.get('/forum/ajaxGetThumbnailInput',function(data,status) {
if( status == 'success' ) {
$(data).appendTo($this.parent().parent());
$this.parent().hide();
}
});
});
$(".destroy").live('click',function() {
if( $(this).parent().siblings().length < 2 ) { // one sibling is the initial anchor
$(".forum_thumbnail_addThumbnail").parent().show();
} else {
var thisAddAnchor = $(this).parent().find('.forum_thumbnail_getInput');
var addAnchor = $(thisAddAnchor).clone();
$(addAnchor).appendTo($(this).parent().prev());
$(thisAddAnchor).remove();
}
$(this).parent().remove();
});
$(".forum_thumbnail_getInput").live('click',function() {
var $this = $(this);
$.get('/forum/ajaxGetThumbnailInput',function(data,status) {
if( status == 'success' ) {
$(data).appendTo($this.parent().parent());
$this.remove();
}
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment