Solved

jQuery sortable no longer working?

Posted on 2013-06-04
5
328 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 56

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 56

Expert Comment

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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
jquery not working after div reload 4 38
Compute age Html 2 27
Collapse in/out from a "a href" each row containing different id 5 47
Javascript: Range object 16 17
There are a couple ways to attach a JavaScript function to dynamically created elements. You can make a new script for each element as it’s created or you can use delegation. Delegation allows a single script that is added at page creation to mat…
I found this questions asking how to do this in many different forums, so I will describe here how to implement a solution using PHP and AJAX. The logical flow for the problem should be: Write an event handler for the first drop down box to get …
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. 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.: (CODE)

696 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