[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 334
  • Last Modified:

jQuery sortable no longer working?

I have been using jQuery sortable, but for some strange reason it's no longer working and I am pretty sure I have not changed my code.
 
The function below is getting the number of menutab but not the position, which show up as undefined?
 
Any ideas on what is going wrong?

 $(function() {
		$("#sortable1").sortable({'update': function(event, ui){
		 
		 var position='';
		  
		  alert("sortable1 this.children.length"+this.children.length);
		  
		  
		  for (i=0; i < this.children.length; i++) {
			if (position.length) {
			  position += ',';
			}
			position += this.children[i].icon_id ;
		  }
			  
			   alert("sortable1"+position);
			   $.ajax({ url: "arrange_icons.php?group_name=C&position="+position });
		}
	  }); 

 });




<div id="slickbox1">
<ul id="sortable1" class="connectedSortable">
        <li class="my_icon" icon_id='99'>
        <div class="menutab">
<div class="menutabicon"><a href="view_tutorials.php"><img src="/admin/icons/images/tutorials.jpg" alt="Help Tutorials" width="50" height="50" border="0"/></a></div>
<div class="menutablink"><a href="view_tutorials.php">Help/Tutorials</a></div>
</div>
    </li>
	    <li class="my_icon" icon_id='57'>
        <div class="menutab">
<div class="menutabicon">
<a href="/admin/add_webpage.php" target="_self"><img src="/admin/icons/images/add_webpage.jpg" alt="Add New Page" width="50" height="50" border="0"/></a></div>
<div class="menutablink">
  <a href="/admin/add_webpage.php" target="_self">Add New WebPage</a></div>
</div>
    </li>
	    <li class="my_icon" icon_id='58'>
        <div class="menutab">
<div class="menutabicon">
<a href="/admin/menu_layout.php" target="_self"><img src="/admin/icons/images/edit_page.jpg" alt="Update Menu" width="50" height="50" border="0"/></a></div>
<div class="menutablink">
  <a href="/admin/menu_layout.php" target="_self">Edit WebPage</a></div>
</div>
    </li>
	    <li class="my_icon" icon_id='76'>
        <div class="menutab">
<div class="menutabicon"><a href="../index.php" target="_blank"><img src="/admin/icons/images/homepage.jpg" alt="Website Home Page" width="50" height="50" border="0" /></a></div>
<div class="menutablink"><a href="../index.php" target="_blank">Website Home Page</a></div>
</div>
    </li>
	</ul>

</div>

Open in new window

0
sabecs
Asked:
sabecs
  • 2
  • 2
1 Solution
 
hieloCommented:
>> this.children
try:
 $(this).children()
0
 
sabecsAuthor Commented:
Thanks hielo, but same problem.
0
 
Julian HansenCommented:
There were several problems - see below for working script
<script type="text/javascript">
 $(function() {
  $("#sortable1").sortable({'update': function(event, ui){
      var position='';

      alert("sortable1 this.children.length"+$(this).children.length);
      var kids = $(this).children();

      for (i=0; i < kids.length; i++) {
        if (position.length) {
          position += ',';
        }
        position += $(kids[i]).attr('icon_id');
      }

      alert("sortable1"+position);
      $.ajax({ url: "arrange_icons.php?group_name=C&position="+position });
    }
  }); 
});
</script>

Open in new window

0
 
sabecsAuthor Commented:
Thanks Julian, that is perfect..
0
 
Julian HansenCommented:
You are welcome - thank for the points.
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now