www.webdeveloper.com
Recent Articles
  • Finding Slow Running Queries in ASE 15
  • A More Advanced Pie Chart for Analysis Services Data
  • Adobe AIR Programming Unleashed: Working with Windows
  • Performance Testing SQL Server 2008's Change Data Capture Functionality
  • The ABC's of PHP: Introduction to PHP
  • How to Migrate from BasicFiles to SecureFiles Storage
  • Why the Twitter Haters Are Wrong
  • User Personalization with PHP: Beginning the Application
  • Whats in an Oracle Schema?
  • Lighting Enhancement in Photoshop
  •  

    Go Back   WebDeveloper.com > Client-Side Development > JavaScript

    JavaScript JavaScript (not Java) Discussion and technical support, including AJAX and frameworks (JQuery, MooTools, Prototype...)

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1  
    Old 11-21-2009, 01:40 PM
    Sean P Kent Sean P Kent is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 2
    AJAX calendar with connected sortable lists

    Hi,
    I have a PHP generated calendar that I have integrated with jQuery's connected sortable lists, so I can drag and sort events. This works great, however I'm trying to also integrate it with a mysql database.
    Here's the problem:
    Each table cell has an id which is the date of that day (2009-11-21), etc..
    When the sortable lists are updated I'm trying to get jquery to pass the date (id) of each list to update the database, but it's only grabbing one date (id) and putting all the lists in one date (table cell)
    Code:
    $(function() {
    		$('.sortable').sortable({
    			connectWith: '.sortable',
    			items: 'li',
    			revert: true,
    			update : function () { 
    			var id = $(this).attr('id');
    			var order = $('.sortable').sortable('serialize',{connected: true});
    			$("#info").load("sort-events.php?date="+id+"&"+order);
    			} 
    		});
    	});
    How can I send each id of every sortable list in the ajax request, so I can update the database correctly?
    Thanks.
    Reply With Quote
      #2  
    Old 11-21-2009, 10:19 PM
    crh3675's Avatar
    crh3675 crh3675 is offline
    Web Demystifier
     
    Join Date: Jan 2004
    Location: Washington DC
    Posts: 1,103
    What is the result of your $_POST vars from within php when "sort-events.php" is called?

    print_r($_POST) should give you the output. Recognize that you are not attaching the "order" results to any variables when making the Ajax request:

    yours
    Code:
    "sort-events.php?date="+id+"&"+order);
    maybe should be
    Code:
    "sort-events.php?date="+id+"&order="+order);
    __________________
    Bittersweet web development.
    Reply With Quote
      #3  
    Old 11-22-2009, 11:49 AM
    Sean P Kent Sean P Kent is offline
    Registered User
     
    Join Date: Nov 2009
    Posts: 2
    Thanks for the reply.
    The $_POST looks like this:
    Array ( [0] => 1 [1] => 1 [2] => 1 ) 2009-11-12
    Now this DOES work, but I only get ONE date in the post vars.
    Can I somehow serialize all the ids of each table cell in the sortable lists?

    I did get this to work by creating a new jquery function for each date in the calendar, but that creates alot of code, and I'm trying to find a better way to do this.
    Right now I have got it working by doing this:
    Code:
    foreach ($cal_date as $id) {
    ?>
    	$(function() {
    		$('#<?php echo $id; ?>').sortable({
    			connectWith: '.sortable',
    			items: 'li',
    			revert: true,
    			update : function () { 
    			var id = $(this).attr('id');
    			var order = $('#<?php echo $id; ?>').sortable('serialize',{connected: false});
    			$("#info").load("sort-events.php?date="+id+"&"+order);
    			} 
    		});
    	});
    <?php 
    }
    So, this DOES work, but is it ok to do it like this? It seems a little wonkey to me, but it does work.

    Thanks for the help.
    Reply With Quote
    Reply

    Bookmarks


    Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
     
    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is Off
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 12:57 PM.



    Acceptable Use Policy


    The Network for Technology Professionals

    Search:

    About Internet.com

    Legal Notices, Licensing, Permissions, Privacy Policy.
    Advertise | Newsletters | E-mail Offers

    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.