We're not getting this done by pasting little bits of code back and  
forth. You're missing something  in here, the server process that does  
the clone in the database has to return the new ID -- that's the only  
place it can come from. If you go back to my example, I had the last  
line of the onSuccess method update the clone's ID with the  
responseText from the server. So in your PHP clone code, make sure  
that the last thing it does is print 'item_someNumber' (where  
someNumber is in fact the most recently added element ID. In MAR, this  
would look like this:

//create_clone.php
$original = $_POST['original'];
if($master = MyActiveRecord::FindById('originals',$original){
        $data = get_object_vars($original);
        array_shift($data); //get rid of the ID
        $new = MyActiveRecord::Create('clones',$data);
        $new->save();
        if(false === $new->get_errors()){
                header('Content-type: text/html; charset=utf-8');
                //this is the part you need:
                print 'item_' .  $new->id;
        }else{
                header('HTTP/1.0 500 Server Error',true,500);
                exit;
        }
}else{
        header('HTTP/1.0 404 Missing',true,404);
}

Walter

On Jun 17, 2009, at 12:57 PM, WLQ wrote:

>
> I'm quite positive that it's something wrong with your script, because
> on drop (clone) this gets inserted in html:
> <li class="clone" id=""><span class="remove">(x)</span>Description</
> li>
>
> Instead of being:
> <li class="clone" id="Item_someNumber">Description<span  
> class="remove">
> (x)</span></li>
>
> For some reason it creates 2 instances instead of one (both of the
> above). If you drag out items in ascending order by the id (1,2,3).
>
>
>> Right! There wasn't any "_" just the id, now everything is fine.
>>
>> The problem I'm seeing now is that when I clone an item, it's  
>> becoming
>> undraggable until you drop on more item.
>> Basically last dropped item won't move, previous items will start
>> moving. It will also create a space "[0] => "
>>
>> You'll understand what I'm talking about when you'll look at the
>> examplehttp://scriptaculous.host22.com/
>>
>>> What does your HTML look like? Are your list element IDs in the form
>>> that Sortable requires?
>>
>>> <ul id="my_sortable_list">
>>> <li id="someString_1">The visible draggable part</li>
>>> <li id="someString_3">The visible draggable part</li>
>>> <li id="someString_4">The visible draggable part</li>
>>> </ul>
>>
>>
>
>> Unless your LIs have an ID and that IDegigins with one or more
> letters
>>
>> a-z, has exactly one underscore in it followed by a unique number
>>> (which should be the ID column value from your database, just to  
>>> tie a
>>> bow on things here) then you won't get anything out of
>>> Sortable.serialize() -- not even an error.
>>
>>> Walter
>>
>>> On Jun 13, 2009, at 12:29 PM, WLQ wrote:
>>
>>>> As you've noted the "post" should give you some feedback like this:
>>
>>>> whatever_your_list_ID_is = Array(
>>>>        0 => 12,
>>>>        1 => 13,
>>>>        2 => 24,
>>>>        3 => 2,
>>>>        4 => 42
>>>> )
>>
>>>> But it does not return any number on the other side:
>>
>>>> Array
>>>> (
>>>>    [whatever_your_list_ID_is] => Array
>>>>        (
>>>>            [0] =>
>>>>            [1] =>
>>>>            [2] =>
>>>>            [3] =>
>>>>        )
>>
>>>> )
>>
>>>>> Yes, mysql_query doesn't return a list, it returns a resource
>>>> iedenttifier. You have to create the list yourself using a loop nd
>>>>> my
> y
> sql_fetch_object or mysql_fetch_array or one of theotther
>>> ""fetchers".
>>
>>
>
>
>
>  efoefefore we go much furthe I need t to remind you that this is not
> a> >> P
>>>>
>>>
>>>>> PHP
> he
> uag
> uages on earth.
>>
>>>>> The example I posted was working code ripped out obusy usy site.
>>>>> However it relies on the MyActiveRecord ORM to do anything.
>>
>>>
>>> define('MYACTIVERECORD_CONCTN_STR''mysyql://use/user::pa  
>>> 'm'mysysql://
>>>>> databasename')R', 'm'mysysql
> re_once('MyActiveRecord.0.5.php');
>>>>> claswiets eendnd MyActyActivvetendns Mds My
>
>> $lisecord{}
>> iveRecordextetendnds getulu,'osipn nSCC),nul,,,po>
> ion nSC');
>>
> ;
>>>
>>>> s'  ts',',
> poon nts',nulu,
>
> ulu,
>
> nSC'n 'n
>>>
>>
>
>
>
>>>  >> >
>> w
> w
>>    w       h//prin->w  />>> >/tioc >cti>ti
>
>
>
> ipn
> tn
> tionitt
> itt th
>>>> Th alis all there is to that. Anything else, I really rethihthis
>> is
>> that> bn:0-312-3178617-31S -3 n-ISn6IS -32-d17't17't knoway be -he  
>> curr784-2 (
>>> is). PHP s). and Mnd s). pm. pmens).ntmeny  by Luke Welling and
> Laura
> homson Thomso
>>> )
>> )
>>
>>> Waltealter
>>
> AMS)
>> *Where " I best"  meanmean eanst".
> t".
>>
>>>>> On Jun 13, 2009 9:04 :04 AM, WLQ wrote:
>>
>>>>>> I've followed your link and tried to buihe listlist as you  
>>>>>> suggested
>>>>>> there. But it gives me.
>>
>>>>>> "ERRNO: 2 TEXT: Invalid argument supplied for foreach()
>>>>>> LOCATION: ...,
>>>>>> line 7"
>>>>>> http://jsbin.com/elocu/edit
>>
>>>>>> re' a list list ofs. (I ums. (I uatabasebaseoblems.ve the st of p
>>>>>>> sortable too).
> clones any item but not
>>>>>>> the
>>>>>>> first, it wil nde nd ertverted".vd". But you wout ont be able to
>>>>>>> move
>>>>>>> it (inside of cloned sortable), when you drag and drop one  
>>>>>>> more > >>
>>>>>>> it >>>>
> apparently
>>>>>>> receives the ability of being dragged. What is extremely weir.
>>>>>>> Here's
>>>>>>> one more weirdness, if you drag items from originals in order  
>>>>>>> they
>>>>>>> appear, then they will be cloned but won't be "reverted". I've  
>>>>>>> also
>>>>>>> added your print_r($_POST) to the update_order.php but it's  
>>>>>>> giving
>>>>>>> some unfair results.
>>>>>>> I've uploaded the whole pack to a "some" website. 
>>>>>>> Checkoutttpthttp://scris.hculous.host22.com/
>>
>> cul>>>> On Jun 8, 1:00 pm, Walter Lee Davis <wam/
> @wdstudio.com>/scote:
>>
>>>>>>>> Gaaaaaa! I always get this backward. As Mr. Wonka w,  d say,
>>>>>>>> "Strike
>>>>>>>> that; reverse it!"
>>
>>> er_yoatv>> your_your_lv = Arrtv = Array(
>>>>>> _ID_is 2   12 => 0>>>
> r_lv          13 =>  >> > >>>
>>>>>        our_lis2,
>>>>>>>>     2  13 ,=>>>> => 0     42 => > >
>>>> => 0     42 => > >>> => 0     42 => 4
>>
>
>
>>>
>>>> => 0     42
>
> O > >> 8, 2009, a,=> 3,
>> ote:>>>>         42 wrote:
>>
>>>>>>>> wrote data generated by Sortablewrotialize looks like this  
>>>>>>>> after
>>>>>>>>> PHP
>>>>>>>>> grabs it from the POST:
>>
>>>>>>>>> whatever_your_list_ID_is = Array(
>>>>>>>>>    0 => 1tev
>>>>>>>>>    1 => 13,
>>>>>>>>>    2 => 24,
>>>>>>>>>    3 => 2,
>>>>>>>>>    4 => 42
>>>>>>>>> )
>>
>>>>>>>>> The keys of the array give the position, the values give the
>>>>>>>>> numerical
>>>>>>>>> part of the list item ID. So in this case, the list looked  
>>>>>>>>> like
>>>>>>>>> this
>>>>>>>>> in the DOM when serialize() wrapped it up:
> >


--~--~---------~--~----~------------~-------~--~----~
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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/prototype-scriptaculous?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to