Jump to content

Jquery remove dropped element


everisk

Recommended Posts

Hi,

 

I have a draggable and droppable element that when item is dropped on to the area it added some elements. However, I want to be able to remove the dropped element. Below is the sample of my code

 

$('#comparecampaign').droppable({
	drop: function(e, ui) {
		if($firstdrop==0) {
			$(this).empty();
			$firstdrop = 1;
		}
		$id = $(ui.draggable).attr('id');
		$text = $(ui.draggable).attr('text');
		$add = '<div id="comparecontainer'+$id+'"><input type="hidden" name="compare[]" value="'+$id+'" id="compare'+$id+'" />'+$text+'<a href="#" class="tooltip" title="Delete campaign from list" class="removecompare" onClick="removeCompareCampaign(\''+$id+'\');" id="'+$id+'">Del</a></div><br />';
		$(this).append($add);
		function removeCompareCampaign($id) {
			$('#comparecontainer'+$id).remove();
		}
	}
});

 

With the above code, I get removeCompareCampaign in not defined in Firebug. How do I get this working?

 

Thank you.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.