I will first explain what I’m trying to do then I will explain why just in case you get bored of reading the whole scenario.
Basically I have some HTML markup stored in a variable I now need to a wait to access the different elements within the variable. For example:
var markUp = "<h3>h3 tag</h3><p>paragraph tag</p>";
What I need to know is if there is a way for me to query the variable to retrieve say the h3 tag, in a similar way you would use the query function ? I have seen some other practices where people append the var to a hidden div then query the div. I would prefer to avoid this but if that is the only way I will proceed.
I have come across this problem whilst developing a drag and drop application, on drop i use a custom creator function to change the items structure once it is dropped.
If further explanation is needed please say, thanks advance Jonathan
You can use
dojo._toDomto create a DOM fragment from your string.The underscore prefix in
_toDommeans that it’s a “private” member method ofdojo. Normally, it’s bad practice to use these as if they were public (like I do here). However, in the case of_toDomI believe it’s generally considered acceptable, and according to this trac entry, it sounds like it’ll be made public in the next version.