Hey all!

I have a problem with the sortable function in IE (I've tested both 7
& 8). It does not occur in Firefox or Chrome.

What is happening is that if a user tries to change the first element
of my sortable list, it does the following:

In IE7, it will not allow the user to change the position of the top
element. It is draggable, but will not move the other elements. It
simply adds a blank space at the top of the element list. Dragging
elements other than the first works just fine.

In IE8, once the user clicks on the top element to drag it, a submit
button in the element goes blank, and if you drag it below any other
element, it will not allow the user to replace it as the top element.
When the user releases the element and it drops below on of the lower
elements, both elements are changed to reflect the element that was
just changed.

Did any of that make sense? I also have several other js scripts on my
application, but when I comment them out, I still get this issue.

Again, it works perfectly in Chrome and Firefox (of course). Why must
IE be the bane of my existence? It seems I spend half my development
time fixing problems for IE. Thanks in advance for the help! I've
included the code below:

Sortable Elements:
if($docs['segmentID1']!=0)
        {
                 $demo = new SortableExample();
                $list = $demo->getSegs(); ?>
    <script>
                        Event.observe(window,'load',init,false);
                        function init() {
                                
Sortable.create('segment_drag',{tag:'div',onUpdate:updateList});
                        }
                        function updateList(container) {
                                var url = 
'../includes/scripts/list_reorder.inc.php';
                                var params = Sortable.serialize(container.id);
                                var ajax = new Ajax.Request(url,{
                                        method: 'post',
                                        parameters: params,
                                        onLoading: 
function(){$('workingMsg').show()},
                                        onLoaded: 
function(){$('workingMsg').hide()}
                                });
                                location.reload(true, 2);
                        }
                </script>
                <?php

        echo('<div id="segment_drag">');

                        foreach($list as $key=>$item) {
                                $key = $key+1;

                        echo('<div id="item_'.$item['id'].'">
                                        <form id="myForm" name="myForm" 
action="invoice.php"
method="post"><input style="float:right" type="submit" name="editSeg'.
$key.'"
                                         id="editSeg'.$key.'" value="Edit 
Segment" />');

                        echo('<br /><strong>Segment Type: </strong>');
                                switch($item['segType'])
                                {
                                        case 1:
                                                echo 'Air';
                                                break;
                                        case 2:
                                                echo 'Car';
                                                break;
                                        case 3:
                                                echo 'Hotel';
                                                break;
                                        case 4:
                                                echo 'Cruise';
                                                break;
                                        case 5:
                                                echo 'Tour / Package';
                                                break;
                                        case 6:
                                                echo 'Insurance / Misc.';
                                                break;
                                }

                                echo('<br />');
                                echo('<span style="float:right"><strong>Depart: 
</
strong>'.strftime("%m/%d/%Y", strtotime($item['depart'])).'</span>');
                                echo('<strong>Supplier: </
strong>'.stripslashes($item['supplier']).'<br />');

                                echo('<span style="float:right"><strong>Return: 
</
strong>'.strftime("%m/%d/%Y", strtotime($item['return'])).'</span>');
                                echo('<strong>Confirmation: 
</strong>'.$item['confirmation'].'<br /
>');

                                echo('<strong>Details: </
strong>'.formatDetails($item['details']).'<br />');

                                echo(' <span 
style="float:right"><strong>Taxes:</strong> '.
$item['taxes'].'</span>');
                                echo('<strong>Base Fare: 
</strong>'.$item['baseFare'].'<br />');

                                echo('<span style="float:right"><strong>Total: 
</strong>'.
$item['total'].'</span>');
                                echo('<strong>Discount: 
</strong>'.$item['discount'].'<br />');

                                echo('<span 
style="float:right"><strong>Balance: </strong>'.
$item['balance'].'</span>');
                                echo('<strong>Payments: 
</strong>'.$item['payments'].' <br />');
                                echo('<hr />');
                                echo('</form>');
                                echo('</div>');
                        }
                echo('</div>');
        }

class SortableExample {

        public function getSegs() {
                if($_SESSION['quoteID'])
                        $type = 'quote';
                else
                        $type = 'invoice';

                $sql = "SELECT * FROM ".$type."s WHERE 
id=".$_SESSION[$type.'ID'];
//              echo $sql;
                $recordSet = mysql_query($sql,$this->conn);
                $row = mysql_fetch_array($recordSet);
                $results = array();

                if($row['customSeg']=='0')
                {
                                $tableC = "CREATE temporary table segs (
                                        `id` int(11) NOT NULL,
                                          `segType` int(11) NOT NULL default 
'0',
                                          `supplier` varchar(20) NOT NULL 
default '',
                                          `depart` date NOT NULL default 
'0000-00-00',
                                          `return` date NOT NULL default 
'0000-00-00',
                                          `confirmation` varchar(15) NOT NULL 
default '',
                                          `details` varchar(200) NOT NULL 
default '',
                                          `baseFare` decimal(10,2) NOT NULL 
default '0.00',
                                          `taxes` decimal(10,2) NOT NULL 
default '0.00',
                                          `discount` decimal(10,2) NOT NULL 
default '0.00',
                                          `total` decimal(10,2) NOT NULL 
default '0.00',
                                          `payments` decimal(10,2) NOT NULL 
default '0.00',
                                          `balance` decimal(10,2) NOT NULL 
default '0.00',
                                          `deposit` tinyint(1) NOT NULL default 
'0',
                                          `final` tinyint(1) NOT NULL default 
'0',
                                          PRIMARY KEY  (`id`)
                                        ) ENGINE=MyISAM  DEFAULT 
CHARSET=latin1";
                                $tableR = @mysql_query($tableC);
                                for($i=1; $i<=3; $i++)
                                {
                                        $segment = 'segmentID'.$i;
                                        $select = "SELECT * FROM segments WHERE 
id = $row[$segment]";
//                                      echo $select.'<br />';
                                        $records = 
mysql_query($select,$this->conn);
                                        if(mysql_num_rows($records)>0)
                                        {
                                                $segs = 
@mysql_fetch_array($records);
                                                $insertQ = "INSERT INTO segs
                                                        (`id`, `segType`, 
`supplier`, `depart`, `return`,
`confirmation` , `details` , `baseFare` ,       `taxes` ,
                                                         `discount` , `total` , 
`payments` , `balance` , `deposit` ,
`final` )
                                                        
VALUES('".$segs['id']."', '".$segs['segType']."', '".
$segs['supplier']."', '".$segs['depart']."',
                                                                
'".$segs['return']."', '".$segs['confirmation']."',
'".addslashes($segs['details'])."', '".$segs['baseFare']."',
                                                                
'".$segs['taxes']."', '".$segs['discount']."', '".
$segs['total']."', '".$segs['payments']."',
                                                                
'".$segs['balance']."', '".$segs['deposit']."', '".
$segs['final']."')";
                                                $insertR = 
@mysql_query($insertQ);
                                                echo $insertQ;
                                        }
                                        else
                                        {
                                                $i=4;
                                        }
                                }
                                $segmentQ = "SELECT * FROM segs ORDER BY depart 
ASC";
        //                      echo '<br />'.$segmentQ;
                                $segmentR = @mysql_query($segmentQ);
                                while($rows = mysql_fetch_array($segmentR)){
                                $results[] = $rows;
                                }
                }
                else
                {
                        for ($i=1; $i<=3; $i++)
                        {
                                $segment = 'segmentID'.$i;
                                if($row[$segment]!=0)
                                {
                                        $select = "SELECT * FROM segments WHERE 
id = $row[$segment]";
                        //              echo $select;
                                        $records = 
mysql_query($select,$this->conn);
                                        $rows = mysql_fetch_array($records);


                                        $results[] = $rows;
                                }
                                else
                                {
                                        $i = 4;
                                }
                        }
                }
                return $results;
        }

        public function updateList($orderArray) {
                if($_SESSION['quoteID'])
                        $type = 'quote';
                else
                        $type = 'invoice';
                $orderid = 1;
                foreach($orderArray as $catid) {
                        $catid = (int) $catid;
                        $sql = "UPDATE ".$type."s SET 
segmentID".$orderid."={$catid},
customSeg='1' WHERE id=".$_SESSION[$type.'ID'];
                        echo $sql;
                        $recordSet = mysql_query($sql,$this->conn);
                        $orderid++;

                }

        }
}

list_reorder.inc.php:
$demo = new SortableExample();
$demo->updateList($_POST['segment_drag']);


-- 
You received this message because you are subscribed to the Google Groups 
"Prototype & script.aculo.us" group.
To post to this group, send email to prototype-scriptaculous@googlegroups.com.
To unsubscribe from this group, send email to 
prototype-scriptaculous+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en.

Reply via email to