Re: [jQuery] Using $ to insert HTML into the page

2006-10-06 Thread Blair Mitchelmore
I'm pretty sure

If I recall correctly, jQuery's element creation technique is to create 
a temporary div (var div = document.createElement('div')) then add the 
html you provided to that elements innerHTML value (div.innerHTML = 
html) and then extracting the div's children (using the appropriate DOM 
method) and appending it to the real document. Hope that helps.

-blair

Matthew Pennell wrote:
> I just can't tell if elements or innerHTML are being inserted. As I 
> understand it, markup that is added using innerHTML cannot be later 
> manipulated by DOM-methods, whereas as DOM inserted (using 
> .createElement and .appendChild) elements can be.
>
> Matthew.


___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Using $ to insert HTML into the page

2006-10-06 Thread Matthew Pennell
Jörn Zaefferer schrieb:>> In the documentation (visualjquery.com  >> version), it says that the $ function, when passed some HTML as a 
>> string, will "create the DOM elements representing that HTML string, >> on the fly". Looking at the code though (the clean function), it appears all it is 
>> doing is using innerHTML - is this the case? If it is, I think the >> documentation should be changed to better represent what is actually >> happening. If not, can someone explain how this works to me please?
> The documentation also says that the created html is "to be (assumedly) > inserted into the document later". That's the important point, after > creating the element, you need to add it to the document using something 
> like appendTo or prependTo. The second example demonstrates that: > $("Hello").appendTo("#body")I understand that, I just can't tell if elements or innerHTML are being inserted. As I understand it, markup that is added using innerHTML cannot be later manipulated by DOM-methods, whereas as DOM inserted (using .createElement and .appendChild) elements can be.
Matthew.
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Using $ to insert HTML into the page

2006-10-05 Thread Scott Sharkey
Jörn Zaefferer wrote:
> Matthew Pennell schrieb:
>> Apologies if this has been raised before - I searched but couldn't 
>> find anything.
>>
>> In the documentation (visualjquery.com  
>> version), it says that the $ function, when passed some HTML as a 
>> string, will "create the DOM elements representing that HTML string, 
>> on the fly".
>>
>> Looking at the code though (the clean function), it appears all it is 
>> doing is using innerHTML - is this the case? If it is, I think the 
>> documentation should be changed to better represent what is actually 
>> happening. If not, can someone explain how this works to me please?
> The documentation also says that the created html is "to be (assumedly) 
> inserted into the document later". That's the important point, after 
> creating the element, you need to add it to the document using something 
> like appendTo or prependTo. The second example demonstrates that: 
> $("Hello").appendTo("#body")

Jorn -- quick question-- does append actually create new DOM nodes as 
children of whatever the target is?

I have an application which is an online quote form.  It is supposed to 
have "line items", which may be of one of 4 types, depending on the 
item.  Each of these line items will be connected via ajax so that I can 
do item lookup as they progress. For instance, they select type A, and 
it put's in a selection box (choose color) where the contents are loaded 
via ajax.  Then, as they choose "red", the next dropdown box is filled, 
with say, size... etc.  So, each line item will have to have some unique 
way to be identified so that I can target them for later calls.

And I want to have an "unlimited" number of line items, if that makes 
sense.  Can I use the append functions to do this?

I hope my question makes sense.  Thanks!

-Scott




___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


Re: [jQuery] Using $ to insert HTML into the page

2006-10-05 Thread Jörn Zaefferer
Matthew Pennell schrieb:
> Apologies if this has been raised before - I searched but couldn't 
> find anything.
>
> In the documentation (visualjquery.com  
> version), it says that the $ function, when passed some HTML as a 
> string, will "create the DOM elements representing that HTML string, 
> on the fly".
>
> Looking at the code though (the clean function), it appears all it is 
> doing is using innerHTML - is this the case? If it is, I think the 
> documentation should be changed to better represent what is actually 
> happening. If not, can someone explain how this works to me please?
The documentation also says that the created html is "to be (assumedly) 
inserted into the document later". That's the important point, after 
creating the element, you need to add it to the document using something 
like appendTo or prependTo. The second example demonstrates that: 
$("Hello").appendTo("#body")
Hope that helps.

-- Jörn

___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/


[jQuery] Using $ to insert HTML into the page

2006-10-05 Thread Matthew Pennell
Apologies if this has been raised before - I searched but couldn't find anything.In the documentation (visualjquery.com version), it says that the $ function, when passed some HTML as a string, will "create the DOM elements representing that HTML string, on the fly".
Looking at the code though (the clean function), it appears all it is doing is using innerHTML - is this the case? If it is, I think the documentation should be changed to better represent what is actually happening. If not, can someone explain how this works to me please?
Thanks,Matthew.
___
jQuery mailing list
discuss@jquery.com
http://jquery.com/discuss/