moltm4785 Posted March 31, 2013 Share Posted March 31, 2013 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); }); } }); }); Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/ Share on other sites More sharing options...
haku Posted March 31, 2013 Share Posted March 31, 2013 $.sortable() is not a jQuery function. Which likely means this is a plugin. If so, then you need to go to the plugin developer, as it is unlikely that any of us will know the internals of this fucntion. Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422038 Share on other sites More sharing options...
ignace Posted March 31, 2013 Share Posted March 31, 2013 @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? Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422051 Share on other sites More sharing options...
moltm4785 Posted March 31, 2013 Author Share Posted March 31, 2013 @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. Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422077 Share on other sites More sharing options...
haku Posted March 31, 2013 Share Posted March 31, 2013 @haku It's not a plugin, like he said it's from jQuery UI. http://jqueryui.com/sortable/ You mean the jQuery plugin, jQuery UI? I did miss that he had said it's from that plugin though. Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422081 Share on other sites More sharing options...
moltm4785 Posted March 31, 2013 Author Share Posted March 31, 2013 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 Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422084 Share on other sites More sharing options...
moltm4785 Posted March 31, 2013 Author Share Posted March 31, 2013 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. Link to comment https://forums.phpfreaks.com/topic/276336-objects-question-about-accessing-elements/#findComment-1422085 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.