| | 658 | }, |
| | 659 | |
| | 660 | placeAt: function(/* String|DomNode|_Widget */reference, /* String?|Int? */position){ |
| | 661 | // summary: Place this widget's domNode reference somewhere in the DOM based |
| | 662 | // on standard dojo.place conventions, or passing a Widget reference that |
| | 663 | // contains and addChild member. |
| | 664 | // |
| | 665 | // description: |
| | 666 | // A convenience function provided in all _Widgets, providing a simple |
| | 667 | // shorthand mechanism to put an existing (or newly created) Widget |
| | 668 | // somewhere in the dom, and allow chaining. |
| | 669 | // |
| | 670 | // reference: |
| | 671 | // The String id of a domNode, a domNode reference, or a reference to a Widget posessing |
| | 672 | // an addChild method. |
| | 673 | // |
| | 674 | // position: |
| | 675 | // If passed a string or domNode reference, the position argument |
| | 676 | // accepts a string just as dojo.place does, one of: "first", "last", |
| | 677 | // "before", or "after". |
| | 678 | // |
| | 679 | // If passed a _Widget reference, and that widget reference has an ".addChild" method, |
| | 680 | // it will be called passing this widget instance into that method, supplying the optional |
| | 681 | // position index passed. |
| | 682 | // |
| | 683 | // example: |
| | 684 | // | // create a Button with no srcNodeRef, and place it in the body: |
| | 685 | // | var button = new dijit.form.Button({ label:"click" }).placeAt(dojo.body()); |
| | 686 | // | // now, 'button' is still the widget reference to the newly created button |
| | 687 | // | dojo.connect(button, "onClick", function(e){ console.log('click'); }); |
| | 688 | // |
| | 689 | // example: |
| | 690 | // | // create a button out of a node with id="src" and append it to id="wrapper": |
| | 691 | // | var button = new dijit.form.Button({},"src").placeAt("wrapper"); |
| | 692 | // |
| | 693 | // example: |
| | 694 | // | // place a new button as the first element of some div |
| | 695 | // | var button = new dijit.form.Button({ label:"click" }).placeAt("wrapper","first"); |
| | 696 | // |
| | 697 | // example: |
| | 698 | // | // create a contentpane and add it to a TabContainer |
| | 699 | // | var tc = dijit.byId("myTabs"); |
| | 700 | // | new dijit.layout.ContentPane({ href:"foo.html", title:"Wow!" }).placeAt(tc) |
| | 701 | // |
| | 702 | // example: |
| | 703 | // | // add a new pane to a BorderContainer and set the content in one pass. |
| | 704 | // | var bc = dijit.byId("bc1"); |
| | 705 | // | new dijit.layout.ContentPane({ |
| | 706 | // | region:"left", |
| | 707 | // | style:"width:100px" |
| | 708 | // | }).placeAt(bc).setContent("<p>wowzers</p>"); |
| | 709 | // |
| | 710 | if(reference["declaredClass"] && reference["addChild"]){ |
| | 711 | reference.addChild(this, position); |
| | 712 | }else{ |
| | 713 | var n = dojo.byId(reference); |
| | 714 | dojo.place(this.domNode, n, position || "last"); |
| | 715 | } |
| | 716 | return this; |