Results 1 to 2 of 2

Thread: setting dropped attribute into variable

  1. #1
    Join Date
    Jun 2006
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default setting dropped attribute into variable

    See code:
    Code:
    $(function() {
    		$( "#catalog" ).accordion();
    		$("#catalog td").livequery(function(){ 
    			$(this).draggable({
    				appendTo: "body",
    				helper: "clone",
    				revert: "invalid"
    			});
    		});
    		$( "#cart ol" ).livequery(function(){ 
    			$(this).droppable({
    				activeClass: "ui-state-default",
    				hoverClass: "ui-state-hover",
    				accept: ":not(.ui-sortable-helper)",
    				drop: function( event, ui ) {
    					$( this ).find( ".placeholder" ).remove();
    					$( "<li></li>" ).text(ui.draggable.attr('id')).appendTo( this );
    					//var divIndex = $(this).attr('id');
    					var droppedId = $(this).ui.draggable.attr('id');
                    	//addToBin(divIndex);
    					addToBin(droppedId);
    				}
    			});
    		}).livequery(function(){ 
    			$(this).sortable({
    			items: "li:not(.placeholder)",
    			sort: function() {
    				// gets added unintentionally by droppable interacting with sortable
    				// using connectWithSortable fixes this, but doesn't allow you to customize active/hoverClass options
    				$( this ).removeClass( "ui-state-default" );
    			}
    		});});
    	});
    Task: I am trying to grab the attributed id number from the item i drag. everything works fine, except for setting the variable value. Id like to set the variable value = to the attribute value so that I Could run a javascript function to update my database.

    this is the part of the code giving me trouble:
    Code:
    var droppedId = $(this).ui.draggable.attr('id');
                    	//addToBin(divIndex);
    					addToBin(droppedId);

    I have a feeling this is something easy but after googling for the better part of the night and trying many different ideas I could not figure out. Thank you in advance for the help everyone.

  2. #2
    Join Date
    Jun 2006
    Posts
    78
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    SOLVED: var droppedId = $(ui.draggable).attr("id");

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •