Solved

jQuery sortable no longer working?

Posted on 2013-06-04
5
329 Views
Last Modified: 2013-06-05
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
Comment
Question by:sabecs
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 82

Expert Comment

by:hielo
ID: 39220976
>> this.children
try:
 $(this).children()
0
 

Author Comment

by:sabecs
ID: 39220995
Thanks hielo, but same problem.
0
 
LVL 57

Accepted Solution

by:
Julian Hansen earned 500 total points
ID: 39221317
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
 

Author Closing Comment

by:sabecs
ID: 39223723
Thanks Julian, that is perfect..
0
 
LVL 57

Expert Comment

by:Julian Hansen
ID: 39223940
You are welcome - thank for the points.
0

Featured Post

Why You Need a DevOps Toolchain

IT needs to deliver services with more agility and velocity. IT must roll out application features and innovations faster to keep up with customer demands, which is where a DevOps toolchain steps in. View the infographic to see why you need a DevOps toolchain.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Chart.js, used properly, can visually add a difference to your charting applications. It engages your visitors and allows them to interact with data they otherwise wouldn't be able to without expensive and complicated systems. For this…
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question