Jump to content

Objects question about accessing elements


Go to solution Solved by moltm4785,

Recommended Posts

A bit of background I am working with the jquery.ui sortable and have run against a bump. When you do the below code you get the following: 0:[object HTMLUListElement]. I need to know how you are supposed to access this objects elements. I don't understand the 0 part for the name. I've tried .item(0) but that errors the page out.
 

	$(function() {
		$('#sort1, #sort2').sortable({
			connectWith : '.sort',
			receive : function(event, ui) {
				$.each(ui.sender, function(name, value) {
					alert(name + ': ' + value);
				});
			}
		});
	});

 

 

 

 

 

@haku It's not a plugin, like he said it's from jQuery UI. http://jqueryui.com/sortable/

 

@OP Read the documentation at http://jqueryui.com/sortable/#connect-lists and at http://api.jqueryui.com/sortable/ and be sure to click on view source.

 

This is how it should work.

	$(function() {
		$('#sort1, #sort2').sortable({
			connectWith : '.sort'
		});
	});
What is it that you want to do exactly? Edited by ignace

 

@haku It's not a plugin, like he said it's from jQuery UI. http://jqueryui.com/sortable/

 

@OP Read the documentation at http://jqueryui.com/sortable/#connect-lists and at http://api.jqueryui.com/sortable/ and be sure to click on view source.

 

This is how it should work.

	$(function() {
		$('#sort1, #sort2').sortable({
			connectWith : '.sort'
		});
	});
What is it that you want to do exactly?

 

What I am trying to do is once you have activated sortable there is a piece called recieve which is an event that is triggered when the connected sortable list accepts something once that is activated you get function(event, ui) the ui has a element in it called sender so ui.sender and sender in itself has an element that is an object that is the sender itself but when you use a loop of $.each(ui.sender, function(name, sender) to see each element in it all it gives is 0:object but I dont' understand how to access this object outside of the $.each since when I do a loop on say ui it stats each piece like sender:object and a view others wchich means to access each you do ui.element like ui.sender. but ui.sender.something is what I'm confused on because all i have is a 0: here and not sure how to grab that. I tried .item(0) this errors out the page and i tried .0 that errors out the page .id gives null of course because the ui.sender.element where element is still technically an object. Hope this helps you understand what I am looking for.

I get that but in any instance when you have an object don't they always state there name? So how do you access this one since its this. The item I am trying to work with is sender.

 

 

ui
Type: Object
 
  • helper
    Type: jQuery
    The jQuery object representing the helper being sorted
  • item
    Type: jQuery
    The jQuery object representing the current dragged element
  • offset
    Type: Object
    The current absolute position of the helper represented as { top, left }
  • position
    Type: Object
    The current position of the helper represented as { top, left }
  • originalPosition
    Type: Object
    The original position of the element represented as { top, left }
  • sender
    Type: jQuery
    The sortable that the item comes from if moving from one sortable to another
  • Solution

Nevermind I figured it out, when your talking about a type jquery everything is accessed by index so ui.sender[0] gives the object as being an li object which then allows for ui.sender[0].id which gives that li objects id.

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.