yui drag and drop

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • yui drag and drop

    HAllo,

    kennt sich jemand mit dem developer kit von yahoo aus?

    ich hab da nämlich mal ein problem.

    ich verwende das drag and drop in zwei liste ul li.

    leider aber, übernimmt er mir die Werte nicht, da ich nicht der fiteste mit javascript bin, finde ich keine lösung.

    http://developer.yahoo.com/yui/examp...d-reorder.html

    ich habe diese Beispiel verwendet und entsprechend meiner Bedürfnisse angepasst.

    Weis wer Rat?

    Das ist hier nur ein Code auszug:
    PHP-Code:
    (function() {
                
                    var 
    Dom YAHOO.util.Dom;
                    var 
    Event YAHOO.util.Event;
                    var 
    DDM YAHOO.util.DragDropMgr;

                    var 
    myLogReader = new YAHOO.widget.LogReader(\"workarea\"); 
            
                    YAHOO.example.DDApp = {
                    init: function() {
                    
                        var rows=3,cols=2,i,j;
                        for (i=1;i<cols+1;i=i+1) {
                            new YAHOO.util.DDTarget('ul'+i);
                        }
                    
                        for (i=1;i<cols+1;i=i+1) {
                            for (j=1;j<rows+1;j=j+1) {
                                new YAHOO.example.DDList('li' + i + '_' + j);
                            }
                        }
                    
                        Event.on('showButton', 'click', this.showOrder);
                        
                    },
                    
                    showOrder: function() {
                        var parseListin = function(ul) {
                            var itemsin = ul.getElementsByTagName('li');
                            var gridin = new Array();
                            gridin[0] = new Object();
                            var pSin = '';
                            for (i=1;i<itemsin.length;i=i+1) {
                                if(i>1) pSin+='&';
                                //pSin+='gridin['+i+'][gridpoint]='+i; 
                                pSin+='&gridin['+i+'][gridid]='+itemsin[i].getAttribute('gridid');
                                pSin+='&gridin['+i+'][inboxid]='+itemsin[i].getAttribute('inboxid');
                            }
                        //YAHOO.log(itemsin, 'info');
                        //alert(pSin);
                        return pSin;
                        };

                        var parseListout = function(ul, title) {
                            var itemsout = ul.getElementsByTagName('li');
                            var gridout = new Array();
                            gridout[0] = new Object();
                            var pSout = '';
                            for (i=1;i<itemsout.length;i=i+1) {
                                if(i>1) pSout+='&';
                                //pSout+='gridout['+i+'][gridpoint]='+i; 
                                pSout+='&gridout['+i+'][gridid]='+itemsout[i].getAttribute('gridid');
                                pSout+='&gridout['+i+'][inboxid]='+itemsout[i].getAttribute('inboxid');
                            }
                        //YAHOO.log(itemsout, 'info');
                        alert(itemsout);
                        return pSout;
                        };
                    
                        var ul1=Dom.get('ul1'), ul2=Dom.get('ul2');

                        var dropin = parseListin(ul1);
                        var dropout = parseListout(ul2);
                        
                        var UpdateInboxOrderAktiv = function(id, url) {

                            var str = id;

                            new Ajax.Request(url, {
                                method: 'post',
                                parameters: str,
                                    onSuccess: function(transport) {
                                        var res = transport.responseText;
                                        if(res) {
                                            //alert('UpdateInboxOrderAktiv' + res);
                                        }
                                        else {
                                            alert('Unerwartete Rückmeldung: ' + res);
                                        }
                                    }
                            });
                        };

                        var UpdateInboxOrderDeaktiv = function(id, url) {

                            var str = id;

                            new Ajax.Request(url, {
                                method: 'post',
                                parameters: str,
                                    onSuccess: function(transport) {
                                        var res = transport.responseText;
                                        if(res) {
                                            //alert('UpdateInboxOrderDeaktiv' + res);
                                        }
                                        else {
                                            alert('Unerwartete Rückmeldung: ' + res);
                                        }
                                    }
                            });
                        };

                        var updatein = UpdateInboxOrderAktiv(dropin, '"
    .GRIDTEXTE::GRID_GEN_DATEI."');
                        var updateout = UpdateInboxOrderDeaktiv(dropout, '"
    .GRIDTEXTE::GRID_GEN_DATEI."');
                        YAHOO.log(updatein, 'info');
                        YAHOO.log(updateout, 'info');
                    }
                };
                
                ///////////////////////////////////////
                // custom drag and drop implementation
                //////////////////////////////////////
                
                YAHOO.example.DDList = function(id, sGroup, config) {
                
                YAHOO.example.DDList.superclass.constructor.call(this, id, sGroup, config);
                
                this.logger = this.logger || YAHOO;
                var el = this.getDragEl();
                Dom.setStyle(el, 'opacity', 0.67); // The proxy is slightly transparent
                
                this.goingUp = false;
                this.lastY = 0;
                };
                
                YAHOO.extend(YAHOO.example.DDList, YAHOO.util.DDProxy, {
                
                startDrag: function(x, y) {
                    this.logger.log(this.id + 'startDrag');
                
                    // make the proxy look like the source element
                    var dragEl = this.getDragEl();
                    var clickEl = this.getEl();
                    Dom.setStyle(clickEl, 'visibility', 'hidden');
                
                    dragEl.innerHTML = clickEl.innerHTML;
                
                    Dom.setStyle(dragEl, 'color', Dom.getStyle(clickEl, 'color'));
                    Dom.setStyle(dragEl, 'backgroundColor', Dom.getStyle(clickEl, 'backgroundColor'));
                    Dom.setStyle(dragEl, 'border', '2px solid gray');
                },
                
                endDrag: function(e) {
                    this.logger.log(this.id + 'endDrag');
                    var srcEl = this.getEl();
                    var proxy = this.getDragEl();
                
                    // Show the proxy element and animate it to the src element's location
                    Dom.setStyle(proxy, 'visibility', '');
                    var a = new YAHOO.util.Motion( 
                    proxy, { 
                        points: { 
                        to: Dom.getXY(srcEl)
                        }
                    }, 
                    0.2, 
                    YAHOO.util.Easing.easeOut 
                    )
                    var proxyid = proxy.id;
                    var thisid = this.id;
                
                    // Hide the proxy and show the source element when finished with the animation
                    a.onComplete.subscribe(function() {
                        Dom.setStyle(proxyid, 'visibility', 'hidden');
                        Dom.setStyle(thisid, 'visibility', '');
                    });
                    a.animate();
                },
                
                onDragDrop: function(e, id) {
                
                    // If there is one drop interaction, the li was dropped either on the list,
                    // or it was dropped on the current location of the source element.
                    if (DDM.interactionInfo.drop.length === 1) {
                
                    // The position of the cursor at the time of the drop (YAHOO.util.Point)
                    var pt = DDM.interactionInfo.point; 
                
                    // The region occupied by the source element at the time of the drop
                    var region = DDM.interactionInfo.sourceRegion; 
                
                    // Check to see if we are over the source element's location.  We will
                    // append to the bottom of the list once we are sure it was a drop in
                    // the negative space (the area of the list without any list items)
                    if (!region.intersect(pt)) {
                        var destEl = Dom.get(id);
                        var destDD = DDM.getDDById(id);
                        destEl.appendChild(this.getEl());
                        destDD.isEmpty = false;
                        DDM.refreshCache();
                    }
                
                    }
                },
                
                onDrag: function(e) {
                
                    // Keep track of the direction of the drag for use during onDragOver
                    var y = Event.getPageY(e);
                
                    if (y < this.lastY) {
                    this.goingUp = true;
                    } else if (y > this.lastY) {
                    this.goingUp = false;
                    }
                
                    this.lastY = y;
                },
                
                onDragOver: function(e, id) {
                
                    var srcEl = this.getEl();
                    var destEl = Dom.get(id);
                
                    // We are only concerned with list items, we ignore the dragover
                    // notifications for the list.
                    if (destEl.nodeName.toLowerCase() == 'li') {
                    var orig_p = srcEl.parentNode;
                    var p = destEl.parentNode;
                
                    if (this.goingUp) {
                        p.insertBefore(srcEl, destEl); // insert above
                    } else {
                        p.insertBefore(srcEl, destEl.nextSibling); // insert below
                    }
                
                    DDM.refreshCache();
                    }
                }
                });
                
                Event.onDOMReady(YAHOO.example.DDApp.init, YAHOO.example.DDApp, true);
                
                })(); </script>" 
    Dazu gibts natürlich noch einen Button, der das Update des js auslöst.
    Er löst auch aus, aber ich bekomme die Werte nicht.

    PHP-Code:
    showOrder: function() {
                        var 
    parseListin = function(ul) {
                            var 
    itemsin ul.getElementsByTagName('li');
                            var 
    gridin = new Array();
                            
    gridin[0] = new Object();
                            var 
    pSin '';
                            for (
    i=1;i<itemsin.length;i=i+1) {
                                if(
    i>1pSin+='&';
                                
    //pSin+='gridin['+i+'][gridpoint]='+i; 
                                
    pSin+='&gridin['+i+'][gridid]='+itemsin[i].getAttribute('gridid');
                                
    pSin+='&gridin['+i+'][inboxid]='+itemsin[i].getAttribute('inboxid');
                            }
                        
    //YAHOO.log(itemsin, 'info');
                        //alert(pSin);
                        
    return pSin;
                        };

                        var 
    parseListout = function(ultitle) {
                            var 
    itemsout ul.getElementsByTagName('li');
                            var 
    gridout = new Array();
                            
    gridout[0] = new Object();
                            var 
    pSout '';
                            for (
    i=1;i<itemsout.length;i=i+1) {
                                if(
    i>1pSout+='&';
                                
    //pSout+='gridout['+i+'][gridpoint]='+i; 
                                
    pSout+='&gridout['+i+'][gridid]='+itemsout[i].getAttribute('gridid');
                                
    pSout+='&gridout['+i+'][inboxid]='+itemsout[i].getAttribute('inboxid');
                            }
                        
    //YAHOO.log(itemsout, 'info');
                        
    alert(itemsout);
                        return 
    pSout;
                        }; 
    Danke !
    gruss pedro
Lädt...
X