Re: [Proto-Scripty] Re: How to create a new DOM-element from a string?

2010-12-07 Thread Walter Lee Davis
That's because I called innerHTML on it at the end, and that returns a  
string. If you then want to create a new element out of that, you  
could try inserting it into your page somewhere with


$('someElementOnYourPage').insert({after: foo});

Of you could just leave the innerHTML part off the end, which would  
leave foo populated with the outer wrapper object created by new  
Element...


Walter

On Dec 7, 2010, at 3:20 AM, Luke wrote:


Hmm, damn. the returned value is still a string :(

On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote:

Thanks Walter!

On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote:




On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote:



It's OT for this list, but have a look at Prototype.js. You can
create a new DOM element in memory, and do all the things you want
to it without ever showing it to the user.



Sorry, this was completely bone-headed of me -- I thought I was on
another list.



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 
.




--
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: How to create a new DOM-element from a string?

2010-12-07 Thread Walter Lee Davis


On Dec 7, 2010, at 10:59 AM, Luke wrote:


Hm ok, hoped there would be a way I could generate a DOM object that
consists of just the HTML (without wrapper) and before I insert it.



There's no need for this, since inserting a string and inserting an  
object have the same effect as long as you're using the  
Element.insert() method.


But you may be doing too many steps here. What does your Ajax method  
return to you? What are the transformations you are performing on it?  
You may be able to do this in fewer stages than you think. Can you  
post a cut-down example of the code returned through Ajax and the code  
after you've massaged it but before you've inserted it in your page?


I suspect you could do all of the work using string methods, and then  
using that same string insert the modified HTML into your page.


Another approach would be to insert the original HTML using insert(),  
then obtain or maintain a handle on the inserted code such that you  
could manipulate it in situ. It would probably happen so quickly that  
nobody would see the modifications take place.


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-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: How to create a new DOM-element from a string?

2010-12-07 Thread Rick . Wellman
Is it just me,... I don't understand what you're even asking/trying to 
accomplish?
What kind of DOM object are you hoping to create?  Call it a potayto, or a 
potahto but any element you insert the HTML into is a wrapper.  

Apologies if this seems terse but I truly do not understand your question/goal.

-Original Message-
From: prototype-scriptaculous@googlegroups.com 
[mailto:prototype-scriptacul...@googlegroups.com] On Behalf Of Luke
Sent: Tuesday, December 07, 2010 9:59 AM
To: Prototype  script.aculo.us
Subject: [Proto-Scripty] Re: How to create a new DOM-element from a string?

Hm ok, hoped there would be a way I could generate a DOM object that
consists of just the HTML (without wrapper) and before I insert it.

On Dec 7, 4:52 pm, Walter Lee Davis wa...@wdstudio.com wrote:
 That's because I called innerHTML on it at the end, and that returns a  
 string. If you then want to create a new element out of that, you  
 could try inserting it into your page somewhere with

 $('someElementOnYourPage').insert({after: foo});

 Of you could just leave the innerHTML part off the end, which would  
 leave foo populated with the outer wrapper object created by new  
 Element...

 Walter

 On Dec 7, 2010, at 3:20 AM, Luke wrote:



  Hmm, damn. the returned value is still a string :(

  On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote:
  Thanks Walter!

  On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote:

  On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote:

  It's OT for this list, but have a look at Prototype.js. You can
  create a new DOM element in memory, and do all the things you want
  to it without ever showing it to the user.

  Sorry, this was completely bone-headed of me -- I thought I was on
  another list.

  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 
  athttp://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.

-- 
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: How to create a new DOM-element from a string?

2010-12-07 Thread Walter Lee Davis
Is mystring what you get back from your Ajax request? Do you control  
the server that sends it?


If you want to end up with the Element div.something inserted  
somewhere on your page, you could do this pretty simply:


var mystring = 'ptext a href=#link/a/ppMore text/pimg  
src=asd /';

//mystring could also be the output from your Ajax request
var myDomObject = new Element('div',{
someProperty: someValue,
 someFunction: function() {}, ...
}).update(mystring);
myDomObject.addClassName('something');
//no need to extend, 'new Element' is already extended
$('myDiv').insert({top: myDomObject});

So you create the outermost level of the DOM object using new Element,  
and that gets you everything you need. You could also pass back from  
your server a JSON graph of the desired element, and pass that to new  
Element directly, and you could skip some of this.


By the way, I do the addClassName thing separately to humor IE, which  
doesn't seem to work when you define the classname in the new Element  
parameters level. I haven't tracked this issue to see if it's been  
fixed in newer versions of the library, I've just been doing it out of  
habit. If anyone can confirm that this is now no longer needed, I'd be  
happy to remove it and put it back in the parameters hash where I  
believe it belongs.


Walter

On Dec 7, 2010, at 12:53 PM, Luke wrote:


Ok, what I wanna do is this:

-
var mystring = 'div class=somethingptext a href=#link/a/
ppMore text/pimg src=asd //div';

var myDomObject = createDomFromString(mystring);

var methodsAndProperties = {someProperty: someValue,
someFunction: function() {}, ... };

Object.extend(myDomObject, methodsAndProperties);

$('myDiv').insert({top: myDomObject});
-

In normal words, what I want to do is create a DOM-Object BEFORE I
insert it, so I can perform some extensions on it, and dont't have to
do:

-
var mystring = 'div class=somethingptext a href=#link/a/
ppMore text/pimg src=asd //div';

var foo = new Element('div', {}).update(mystring);

var myDomObject = foo.select('.something').first();

Object.extend(myDomObject, methodsAndProperties);

$('myDiv').insert({top: myDomObject});
-

or even insert it, and then search for it.


On Dec 7, 5:10 pm, Rick.Wellman rick.well...@kiewit.com wrote:
Is it just me,... I don't understand what you're even asking/trying  
to accomplish?
What kind of DOM object are you hoping to create?  Call it a  
potayto, or a potahto but any element you insert the HTML into is  
a wrapper.


Apologies if this seems terse but I truly do not understand your  
question/goal.




-Original Message-
From: prototype-scriptaculous@googlegroups.com [mailto:prototype-scriptaculous@googlegroups.com 
] On Behalf Of Luke

Sent: Tuesday, December 07, 2010 9:59 AM
To: Prototype  script.aculo.us
Subject: [Proto-Scripty] Re: How to create a new DOM-element from a  
string?


Hm ok, hoped there would be a way I could generate a DOM object that
consists of just the HTML (without wrapper) and before I insert it.

On Dec 7, 4:52 pm, Walter Lee Davis wa...@wdstudio.com wrote:
That's because I called innerHTML on it at the end, and that  
returns a

string. If you then want to create a new element out of that, you
could try inserting it into your page somewhere with



$('someElementOnYourPage').insert({after: foo});



Of you could just leave the innerHTML part off the end, which would
leave foo populated with the outer wrapper object created by new
Element...



Walter



On Dec 7, 2010, at 3:20 AM, Luke wrote:



Hmm, damn. the returned value is still a string :(



On Dec 7, 9:16 am, Luke kickingje...@gmail.com wrote:

Thanks Walter!



On Dec 6, 6:28 pm, Walter Lee Davis wa...@wdstudio.com wrote:



On Dec 6, 2010, at 12:12 PM, Walter Lee Davis wrote:



It's OT for this list, but have a look at Prototype.js. You can
create a new DOM element in memory, and do all the things you  
want

to it without ever showing it to the user.


Sorry, this was completely bone-headed of me -- I thought I was  
on

another list.



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 
athttp://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-scriptaculous@googlegroups.com 
.
To unsubscribe from this group, send email to prototype-scriptaculous+unsubscr...@googlegroups.com 
.
For more options, visit this group athttp://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