[Proto-Scripty] Re: Cloning/moving an element!?

2010-06-21 Thread T.J. Crowder
Hi,

For cloning, there's always Element#clone[1]. That clones the node
using the underlying DOM cloneNode function, and also handles anything
Prototype might have stored on the node.

 Apart from cloning an element I also needed to move an element from
 one div to another and I came up with this function...
 [snip]
 I don't like the switch part very much and tried to use the position
 variable directly but that somehow didn't work...anyone knows why?
 [snip]
                 newParent.insert({position: element});

Because that creates a property called position on the options
object, exactly the way your earlier code

                 newParent.insert({top: element});

...creates a property called top on the options object. The left-
hand side of a property initializer (and for that matter an
assignment) is used as the name of the property (or variable) to
create, not as a variable _containing_ the name of the property/
variable.

It is possible to do what you want, though:

Element.addMethods({
        appendTo: function(element, newParent, position) {
var options;
element = $(element);
newParent = $(newParent);
options = {};
options[position] = element;
newParent.insert(options);
return element;
    }});

...because the bracketed notation for property access uses strings for
property names, and lets you get the property name string from a
variable.

[1] http://api.prototypejs.org/dom/element/clone/

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


On Jun 20, 11:48 pm, David Behler d.beh...@gmail.com wrote:
 Hi guys,

 while looking for a way to clone an element, I stumbled upon this
 thread from 2007:

 http://groups.google.com/group/prototype-core/browse_thread/thread/9e...

 Any chance this is some when gonna end up in the core? I think this is
 function might be pretty useful sometimes.

 Apart from cloning an element I also needed to move an element from
 one div to another and I came up with this function which is basically
 a wrapper for the insert() function:

 Element.addMethods({
         appendTo: function(element, newParent, position) {
                 element = $(element);
                 newParent = $(newParent);
                 switch(position) {
                         case 'top':
                                 newParent.insert({top: element});
                                 break;
                         case 'bottom':
                                 newParent.insert({bottom: element});
                                 break;
                         case 'before':
                                 newParent.insert({before: element});
                                 break;
                         case 'after':
                                 newParent.insert({after: element});
                                 break;
                 }
                 return element;
         }

 });

 I don't like the switch part very much and tried to use the position
 variable directly but that somehow didn't work...anyone knows why?

 Element.addMethods({
         appendTo: function(element, newParent, position) {
                 element = $(element);
                 newParent = $(newParent);
                 newParent.insert({position: element});
                 return element;
         }});

 $('test').appendTo('test2', 'top');

 Using this function Firebug shows this error: insert is not a
 function.

 Anyway, maybe someone else finds this useful aswell :)

 David

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



Re: [Proto-Scripty] Re: Cloning/moving an element!?

2010-06-21 Thread David Behler

Hi,

thansk for the explantation. Makes sense now.

I totally forgot about the new API docs and only looked at the old docs 
(http://www.prototypejs.org/api/element) where the method wasn't around yet.


David

Am 21.06.2010 08:37, schrieb T.J. Crowder:

Hi,

For cloning, there's always Element#clone[1]. That clones the node
using the underlying DOM cloneNode function, and also handles anything
Prototype might have stored on the node.

   

Apart from cloning an element I also needed to move an element from
one div to another and I came up with this function...
[snip]
I don't like the switch part very much and tried to use the position
variable directly but that somehow didn't work...anyone knows why?
[snip]
 newParent.insert({position: element});
 

Because that creates a property called position on the options
object, exactly the way your earlier code

   

 newParent.insert({top: element});
 

...creates a property called top on the options object. The left-
hand side of a property initializer (and for that matter an
assignment) is used as the name of the property (or variable) to
create, not as a variable _containing_ the name of the property/
variable.

It is possible to do what you want, though:

 Element.addMethods({
 appendTo: function(element, newParent, position) {
 var options;
 element = $(element);
 newParent = $(newParent);
 options = {};
 options[position] = element;
 newParent.insert(options);
 return element;
 }});

...because the bracketed notation for property access uses strings for
property names, and lets you get the property name string from a
variable.

[1] http://api.prototypejs.org/dom/element/clone/

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


On Jun 20, 11:48 pm, David Behlerd.beh...@gmail.com  wrote:
   

Hi guys,

while looking for a way to clone an element, I stumbled upon this
thread from 2007:

http://groups.google.com/group/prototype-core/browse_thread/thread/9e...

Any chance this is some when gonna end up in the core? I think this is
function might be pretty useful sometimes.

Apart from cloning an element I also needed to move an element from
one div to another and I came up with this function which is basically
a wrapper for the insert() function:

Element.addMethods({
 appendTo: function(element, newParent, position) {
 element = $(element);
 newParent = $(newParent);
 switch(position) {
 case 'top':
 newParent.insert({top: element});
 break;
 case 'bottom':
 newParent.insert({bottom: element});
 break;
 case 'before':
 newParent.insert({before: element});
 break;
 case 'after':
 newParent.insert({after: element});
 break;
 }
 return element;
 }

});

I don't like the switch part very much and tried to use the position
variable directly but that somehow didn't work...anyone knows why?

Element.addMethods({
 appendTo: function(element, newParent, position) {
 element = $(element);
 newParent = $(newParent);
 newParent.insert({position: element});
 return element;
 }});

$('test').appendTo('test2', 'top');

Using this function Firebug shows this error: insert is not a
function.

Anyway, maybe someone else finds this useful aswell :)

David
 
   


--
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-scriptacul...@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: Cloning/moving an element!?

2010-06-21 Thread T.J. Crowder
Hi,

No worries. I didn't realize Element#clone was that new, I'd better go
check my projects to see if I'm using cloneNode directly (if so,
probably best to start using the wrapper instead).

-- T.J. :-)

On Jun 21, 9:10 am, David Behler d.beh...@gmail.com wrote:
 Hi,

 thansk for the explantation. Makes sense now.

 I totally forgot about the new API docs and only looked at the old docs
 (http://www.prototypejs.org/api/element) where the method wasn't around yet.

 David

 Am 21.06.2010 08:37, schrieb T.J. Crowder:



  Hi,

  For cloning, there's always Element#clone[1]. That clones the node
  using the underlying DOM cloneNode function, and also handles anything
  Prototype might have stored on the node.

  Apart from cloning an element I also needed to move an element from
  one div to another and I came up with this function...
  [snip]
  I don't like the switch part very much and tried to use the position
  variable directly but that somehow didn't work...anyone knows why?
  [snip]
                   newParent.insert({position: element});

  Because that creates a property called position on the options
  object, exactly the way your earlier code

                   newParent.insert({top: element});

  ...creates a property called top on the options object. The left-
  hand side of a property initializer (and for that matter an
  assignment) is used as the name of the property (or variable) to
  create, not as a variable _containing_ the name of the property/
  variable.

  It is possible to do what you want, though:

       Element.addMethods({
           appendTo: function(element, newParent, position) {
               var options;
               element = $(element);
               newParent = $(newParent);
               options = {};
               options[position] = element;
               newParent.insert(options);
               return element;
       }});

  ...because the bracketed notation for property access uses strings for
  property names, and lets you get the property name string from a
  variable.

  [1]http://api.prototypejs.org/dom/element/clone/

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

  On Jun 20, 11:48 pm, David Behlerd.beh...@gmail.com  wrote:

  Hi guys,

  while looking for a way to clone an element, I stumbled upon this
  thread from 2007:

 http://groups.google.com/group/prototype-core/browse_thread/thread/9e...

  Any chance this is some when gonna end up in the core? I think this is
  function might be pretty useful sometimes.

  Apart from cloning an element I also needed to move an element from
  one div to another and I came up with this function which is basically
  a wrapper for the insert() function:

  Element.addMethods({
           appendTo: function(element, newParent, position) {
                   element = $(element);
                   newParent = $(newParent);
                   switch(position) {
                           case 'top':
                                   newParent.insert({top: element});
                                   break;
                           case 'bottom':
                                   newParent.insert({bottom: element});
                                   break;
                           case 'before':
                                   newParent.insert({before: element});
                                   break;
                           case 'after':
                                   newParent.insert({after: element});
                                   break;
                   }
                   return element;
           }

  });

  I don't like the switch part very much and tried to use the position
  variable directly but that somehow didn't work...anyone knows why?

  Element.addMethods({
           appendTo: function(element, newParent, position) {
                   element = $(element);
                   newParent = $(newParent);
                   newParent.insert({position: element});
                   return element;
           }});

  $('test').appendTo('test2', 'top');

  Using this function Firebug shows this error: insert is not a
  function.

  Anyway, maybe someone else finds this useful aswell :)

  David

-- 
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-scriptacul...@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: Scriptaculous and !--include virtual=xxx.html--

2010-06-21 Thread Scott
is your html file in a virtual directory? also this include tag will
only work if your page is being hosted on an asp server or your local
windows machine as a website through IIS

On Jun 19, 6:56 am, Avram abas...@mitre.org wrote:
 I tried including the Scriptaculous code in an external html file and
 call it with a !--include virtual=xxx.html--?  This didn't work,
 Should it work?  Is there another way to call Scriptaculous code from
 an an external file using HTML and CSS?

-- 
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-scriptacul...@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] readyState always undefined in Safari 5

2010-06-21 Thread mjparme
I recently installed Safari 5 and now when I juse Ajax.Request the
readyState of the xmlDoc is always undefined.

It is retrieving the document just fine (Safari 5 has a great
JavaScript debugger and I can see the contents of the document in the
debugger). However the readyState just isn't set correctly.

I used prototype.js just fine with Safari 4. The code that worked in
Safari 4 also has the same problem now in Safari 5.

Has any else noticed this?

I am leaning toward it being a Safari 5 bug; however, does anyone have
insight or work arounds?

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



Re: [Proto-Scripty] Scriptaculous and !--include virtual=xxx.html--

2010-06-21 Thread Jeff C
Is your server/host/directory set up to allow parsing of includes? Can
you successfully include other HTML files? Or is the one you mentioned
failing while other files work without error? If NO files are being
included, you will need to look into setting this up for your server.
I say this because the code you provided is handled by the server
itself. And the server needs to properly configured to allow your user
to handle this request.

You asked Should it work?  It should, when the server is setup to
allow it. When properly configured, the server will return the
complete file contents of xxx.html along with the parent HTML. To the
browser it'll just look like one big data stream of HTML, and not
multiple files.

Also, Scott is partially right. These includes can only work on a
server that is properly set up to handle parsing / including /
performing some magic. The server can be can any platform/technology
that supports this functionality. I would start there, since this is
most likely not a Scripty level issue.  And if it is, I am sure people
here will let us know :)

Hope this helps.

- J e f f  C o n k l i n -
- http://www.getoutsidenj.com
- http://twitter.com/GetOutsideNJ
- http://www.carabs.com


On Sat, Jun 19, 2010 at 9:56 AM, Avram abas...@mitre.org wrote:
 I tried including the Scriptaculous code in an external html file and
 call it with a !--include virtual=xxx.html--?  This didn't work,
 Should it work?  Is there another way to call Scriptaculous code from
 an an external file using HTML and CSS?

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



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



Re: [Proto-Scripty] Re: Scriptaculous and !--include virtual=xxx.html--

2010-06-21 Thread Walter Lee Davis
Well, maybe on Apache with SSI[1] on -- that's where the feature was  
invented.


Walter

1. http://httpd.apache.org/docs/1.3/howto/ssi.html

On Jun 21, 2010, at 11:51 AM, Scott wrote:


also this include tag will
only work if your page is being hosted on an asp server or your local
windows machine as a website through IIS


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