thinkt4nk
2/25/2011 - 3:13 PM

mto inputs

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();
				}
			});		
		});
	});