How to add a template widget inside a contentpane

View: New views
2 Messages — Rating Filter:   Alert me  

How to add a template widget inside a contentpane

by abhishek dastidar :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi All,

I have declared a template using dijit.declaration which is a
borderContainer with a form to add/view a record something like this:

<div dojoType="dijit.Declaration" widgetClass="user.UserDetails">
<div dojoType="dijit.layout.BorderContainer" dojoAttachPoint="container"
id="${cid}">

<div dojoType="dijit.layout.ContentPane" region="center"
class="detailsPane">
<form id="${cid}form" dojoType="dijit.form.Form" onSubmit="return false">
     [...]


Earlier I had a parent tabContainer on to which I did an addChild to add
this widget like this:

[...]
     // Creates a tab adding a new user and returns its reference
     var newTab = new user.UserDetails({cid:
'container'+paneId++}).container;
     var form = dijit.byId(newTab.id+'form');

     dojo.mixin(newTab,
                 { title: '<img src="/misc/user-add_22x22.png" alt=""
class="tabTitleIcon" />Add User',
                     initialAttrsValues: {},
                     autoFilledValues: {},
                     onClose: function(pane, tab)
                             {
                               [...]
                             }

                             tabs.selectChild(userTab);
                             return true;
                             }
                 });
      tabs.addChild(newTab, index<0?tabs.getChildren().length:index);
      tabs.selectChild(newTab);
     return newTab;
[...]

Now I want the same templated widget to be in side a contentPane so I
changed the line :
      tabs.addChild(newTab, index<0?tabs.getChildren().length:index);   to

       dijit.byId("holder").attr("content", newTab);

After this I get an error saying:

Error parsing in _ContentSetter#Setter_tabs2_3 [ Error: Tried to
register widget with id==container1 but that id is already registered ]
<javascript:void(0);>

Can someone tell me how can I accomplish this ?

Regards,
Abhi




_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest

Re: How to add a template widget inside a contentpane

by Bill Keese-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Maybe you can reduce this down to a smaller testcase, it's hard to follow the description with everything involved.

The problem is that you tried to create two widgets with id=container1 without deleting the original widget first, but I can't tell where you are creating that widget either time.

On Thu, Nov 5, 2009 at 12:10 AM, abhi <abhi@...> wrote:
Hi All,

I have declared a template using dijit.declaration which is a
borderContainer with a form to add/view a record something like this:

<div dojoType="dijit.Declaration" widgetClass="user.UserDetails">
<div dojoType="dijit.layout.BorderContainer" dojoAttachPoint="container"
id="${cid}">

<div dojoType="dijit.layout.ContentPane" region="center"
class="detailsPane">
<form id="${cid}form" dojoType="dijit.form.Form" onSubmit="return false">
    [...]


Earlier I had a parent tabContainer on to which I did an addChild to add
this widget like this:

[...]
    // Creates a tab adding a new user and returns its reference
    var newTab = new user.UserDetails({cid:
'container'+paneId++}).container;
    var form = dijit.byId(newTab.id+'form');

    dojo.mixin(newTab,
                { title: '<img src="/misc/user-add_22x22.png" alt=""
class="tabTitleIcon" />Add User',
                    initialAttrsValues: {},
                    autoFilledValues: {},
                    onClose: function(pane, tab)
                            {
                              [...]
                            }

                            tabs.selectChild(userTab);
                            return true;
                            }
                });
     tabs.addChild(newTab, index<0?tabs.getChildren().length:index);
     tabs.selectChild(newTab);
    return newTab;
[...]

Now I want the same templated widget to be in side a contentPane so I
changed the line :
     tabs.addChild(newTab, index<0?tabs.getChildren().length:index);   to

      dijit.byId("holder").attr("content", newTab);

After this I get an error saying:

Error parsing in _ContentSetter#Setter_tabs2_3 [ Error: Tried to
register widget with id==container1 but that id is already registered ]
<javascript:void(0);>

Can someone tell me how can I accomplish this ?

Regards,
Abhi




_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest


_______________________________________________
FAQ: http://dojotoolkit.org/support/faq
Book: http://docs.dojocampus.org
Dojo-interest@...
http://mail.dojotoolkit.org/mailman/listinfo/dojo-interest