[Proto-Scripty] Re: Sort Children of a DIV without using Element#remove

2011-02-23 Thread RobG


On Feb 24, 2:21 am, Walter Lee Davis  wrote:
> I believe this is a requirement -- that I not use remove -- because  
> the elements I'm trying to move around all have form element observers  
> attached directly to their children, and I am pretty sure this will  
> mess me up. Please let me know if that's not true and I don't need to  
> worry.

You don't have to remove elements to move them. Just append them to
their new parent, that's it:

  $('foo').appendChild($('bar'));

or in plain terms:

 
document.getElementById('foo').appendChild(document.getElementById('bar'));

http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-184E7107 >


--
Rob

-- 
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.



[Proto-Scripty] Sort Children of a DIV without using Element#remove

2011-02-23 Thread Walter Lee Davis
I believe this is a requirement -- that I not use remove -- because  
the elements I'm trying to move around all have form element observers  
attached directly to their children, and I am pretty sure this will  
mess me up. Please let me know if that's not true and I don't need to  
worry.


Here's a thumbnail of what's in the page:

div.captions
form
div.caption
input.start
/div
div.caption
input.start
/div
...
/form
/div

And there's more than one such group on the page. What I need to do is  
loop through the input.start elements in each div.captions group, and  
re-sort their parent divs inside the form so they appear in their  
start order. I want to fire this whenever a start time is updated, and  
I already have a custom event listener where I can slot that in.


My initial pass at this would be to get my collection:

$$('div.captions form').each(function(elm){
var parent = elm;
var list = elm.select('div.caption');
list.sortBy( someMagicFunctionHere );
list.each(function(el){
parent.insert(el.remove());
});
});

But if I do that, won't I kill the form element observers that are  
attached to my input.start elements?


Is there another way (maybe just a native DOM thing) to change the  
order of elements without removing them from the page in the process?


Thanks,

Walter

--
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.



[Proto-Scripty] Re: Ajax.Request with an incorrect Header

2011-02-23 Thread T.J. Crowder
Hi,

What you've quoted here:

> Access-Control-Request-Headers=remote_user,x-prototype-version,x-

...isn't a request header. It looks like a response header from a
server that accepts CORS[1] requests and (for its own reasons) decided
to make your request headers all lowercase.

I just tried your code with Prototype 1.7 (http://jsbin.com/ikere3),
and the actual *request* header sent (according to Chrome, and
separately according to Firebug), was indeed REMOTE_USER with the
value I gave ("foo", in my case).

[1] http://www.w3.org/TR/access-control/

HTH,
--
T.J. Crowder
Independent Software Engineer
tj / crowder software / com
www / crowder software / com


On Feb 23, 3:22 pm, RudyWI  wrote:
> Hi,
>
> I'am trying to use Ajax.Request to send a GET request with specific
> values in header part.
> I use the following code :
>
> function sendMyRequest(url, user) {
>         var myAjax = new Ajax.Request(url, {
>                 method: 'get',
>                 requestHeaders: { REMOTE_USER:user },
>                 onSuccess: function() { alert("OK"); },
>                 onFailure: function() { alert("KO"); }
>         });
>
> }
>
> After I invoked this function, the request header sent is :
>
> Host=*
> ...
> Access-Control-Request-Method=GET
> Access-Control-Request-Headers=remote_user,x-prototype-version,x-
> requested-with
>
> So I don't have a valid field for "REMOTE_USER", as defined in my
> function.
> I want a request Header similar to :
>
> Host=*
> ...
> REMOTE_USER=
>
> How to do it ?
>
> Thanks

-- 
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.



[Proto-Scripty] Ajax.Request with an incorrect Header

2011-02-23 Thread RudyWI
Hi,

I'am trying to use Ajax.Request to send a GET request with specific
values in header part.
I use the following code :

function sendMyRequest(url, user) {
var myAjax = new Ajax.Request(url, {
method: 'get',
requestHeaders: { REMOTE_USER:user },
onSuccess: function() { alert("OK"); },
onFailure: function() { alert("KO"); }
});
}

After I invoked this function, the request header sent is :

Host=*
...
Access-Control-Request-Method=GET
Access-Control-Request-Headers=remote_user,x-prototype-version,x-
requested-with

So I don't have a valid field for "REMOTE_USER", as defined in my
function.
I want a request Header similar to :

Host=*
...
REMOTE_USER=

How to do it ?

Thanks

-- 
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.