[Dojo-interest] remove node from parser?

Maulin Shah maulinpshah at gmail.com
Sat Aug 9 03:55:13 UTC 2008


oh, and dijit.Declaration solves this problem via:

var src = this.srcNodeRef.parentNode.removeChild(this.srcNodeRef);

but I can't use this if I want to be able to have both STATIC and  
DYNAMIC children in the container.

But since this works, I had hoped that .orphan() would work. but,  
alas, it does not!


On Aug 8, 2008, at 8:53 PM, Maulin Shah wrote:

> so here is the details of what i am doing, and how i solved it, in  
> case anyone is interested in why I asked. I am creating a derivative  
> of StackContainer, where your stacks are generated based on your  
> provided template, with parameters of your template replaced by the  
> properties of an array or the values of a store item, and then  
> instantiated only when the particular child is displayed.
>
> So the ideal usage would be:
>
> <div dojoType="my.DynamicTabContainer" titleAttribute="title"  
> store="myStore" query="{foo:'bar'}">
> 	<div dojoType="dijit.layout.ContentPane" title="All">
> 		This is a static tab pane.
> 	</div>
> 	<div dynamic="true">
> 		this is a dynamic pane for ${label}!
> 	</div>
> </div>
>
> Well this works fine. To instantiate this, I do dojo.query(">  
> dynamic").orphan(), and save the innerHTML. I create an empty  
> ContentPane with the title of the store item's titleAttribute.
>
> But obviously this is limited, I want to be able to embed dijits!
>
> <div dynamic="true">
> 	<table dojoType="dojox.grid.DataGrid" store="someOtherStore"  
> query="{bar:'${someThingIFilterOn}'">
> 		//snip
> 	<table>
> </div>
>
> but the problem is that the table is instantiated with the fake  
> query, and I only want it instantiated once someone clicks on that  
> ContentPane.
>
> So as stated before, I first tried to delete the node after saving  
> the innerHTML, then I tried changing the attributes. All sorts of  
> stuff. But now I know it doesn't work. So the solution is simple.  
> Inside a DynamicContainer, you simply can't use the attribute  
> dojoType. If you want a dijit you must use the attribute  
> dynamicDojoType (which parser doesn't use). Then I .replace()  
> dynamicDojoType with dojoType when I instantiate the string. (via  
> ContentPanet.attr('content', str))
>
> It just felt a little hacky doing it that way. But it works, so, I'm  
> gonna "set it and forget it"!
>
> :-)
>
>
> thanks for your input guys. I've got some details about the  
> evolution of this widget at: http://blog.medryx.org/2008/07/29/a-dynamic-tab-container/
>
>
>
> On Aug 8, 2008, at 8:37 PM, Karl Tiedt wrote:
>
>> If you are calling the parser (dojo.parser.parse(); ... it is  
>> impossible AFAIK... if you want to get creative you could do a  
>> query yourself and instantiate each dijit manually via a forEach  
>> across the nodelist and during the forEach compare the node to a  
>> "ignore list" and skip it....
>>
>> -Karl Tiedt
>>
>>
>> On Fri, Aug 8, 2008 at 10:22 PM, Maulin Shah  
>> <maulinpshah at gmail.com> wrote:
>> oh. actually its not so much that i thought they were listening  
>> creatures as that i thought they would return the same INSTANCE of  
>> the node. but so long as I know its IMPOSSIBLE, then I have plenty  
>> of ways to work around the problem.
>> thanks!
>>
>> -maulin
>>
>> On Aug 8, 2008, at 8:11 PM, Karl Tiedt wrote:
>>
>>> You are assuming that a NodeList is a living creature that  
>>> automatically updates anytime the DOM changes.. .and that just  
>>> isnt efficient... NodeLists are static until you call a new query  
>>> to the same var name...
>>>
>>> -Karl Tiedt
>>>
>>>
>>> On Fri, Aug 8, 2008 at 6:36 PM, Maulin Shah, MD <maulinpshah at gmail.com 
>>> > wrote:
>>> I was afraid of that. But I still don't understand why?
>>>
>>> if you do a dojo.query() and get a NodeList. call it A
>>>
>>> then do a differnet dojo.query and get a different NodeList that  
>>> has some intersection with the first. call it B
>>>
>>> then when you change the attributes of the nodes in B that are  
>>> also in B, shouldn't they also be changed in A?
>>>
>>>
>>> On Fri, Aug 8, 2008 at 12:04 PM, Morgan C. Benton <morgan at morphatic.com 
>>> > wrote:
>>> Hi Maulin,
>>>
>>> When does the parser get triggered?  If you've got it in
>>> djConfig="parseOnLoad:true" then I don't think there's an easy way  
>>> to
>>> exempt a node from parsing.  However, if you initiate the parser
>>> manually then you can choose when and over what scope of elements it
>>> gets called.  For example, the code below would parse any elements
>>> within the element with id="foo" when the page loads, but would not
>>> parse any elements outside of foo.
>>>
>>> dojo.addOnLoad(function() {
>>>    var foo = dojo.byId("foo");
>>>    dojo.parser.parse(foo);
>>> });
>>>
>>> Of course the other option is not to include the nodes with
>>> dojoType="..." in your HTML and add them dynamically later when  
>>> you want
>>> them.
>>>
>>> hth,
>>> Morgan
>>>
>>>
>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at dojotoolkit.org
>>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>>>
>>>
>>> -- 
>>> -maulin
>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at dojotoolkit.org
>>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>>
>>>
>>> _______________________________________________
>>> FAQ: http://dojotoolkit.org/support/faq
>>> Book: http://dojotoolkit.org/docs/book
>>> Forums: http://dojotoolkit.org/forum
>>> Dojo-interest at dojotoolkit.org
>>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at dojotoolkit.org
>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>>
>>
>> _______________________________________________
>> FAQ: http://dojotoolkit.org/support/faq
>> Book: http://dojotoolkit.org/docs/book
>> Forums: http://dojotoolkit.org/forum
>> Dojo-interest at dojotoolkit.org
>> http://turtle.dojotoolkit.org/mailman/listinfo/dojo-interest
>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://turtle.dojotoolkit.org/pipermail/dojo-interest/attachments/20080808/7cf4910c/attachment.html 


More information about the Dojo-interest mailing list