Last change
on this file since 256 was
256,
checked in by hendrikvanantwerpen, 13 years ago
|
Reworked project structure based on REST interaction and Dojo library. As
soon as this is stable, the old jQueryUI branch can be removed (it's
kept for reference).
|
File size:
1.1 KB
|
Line | |
---|
1 | define([ |
---|
2 | "dojo/_base/lang", |
---|
3 | "dojo/dom", |
---|
4 | "../Context", |
---|
5 | "../dom", |
---|
6 | "../_base" |
---|
7 | ], function(lang,dom,ddc,dddom,dd){ |
---|
8 | /*===== |
---|
9 | dd = dojox.dtl; |
---|
10 | =====*/ |
---|
11 | lang.getObject("dojox.dtl.render.dom", true); |
---|
12 | |
---|
13 | dd.render.dom.Render = function(/*DOMNode?*/ attachPoint, /*dojox.dtl.DomTemplate?*/ tpl){ |
---|
14 | this._tpl = tpl; |
---|
15 | this.domNode = dom.byId(attachPoint); |
---|
16 | } |
---|
17 | lang.extend(dd.render.dom.Render, { |
---|
18 | setAttachPoint: function(/*Node*/ node){ |
---|
19 | this.domNode = node; |
---|
20 | }, |
---|
21 | render: function(/*Object*/ context, /*dojox.dtl.DomTemplate?*/ tpl, /*dojox.dtl.DomBuffer?*/ buffer){ |
---|
22 | if(!this.domNode){ |
---|
23 | throw new Error("You cannot use the Render object without specifying where you want to render it"); |
---|
24 | } |
---|
25 | |
---|
26 | this._tpl = tpl = tpl || this._tpl; |
---|
27 | buffer = buffer || tpl.getBuffer(); |
---|
28 | context = context || new ddc(); |
---|
29 | |
---|
30 | var frag = tpl.render(context, buffer).getParent(); |
---|
31 | if(!frag){ |
---|
32 | throw new Error("Rendered template does not have a root node"); |
---|
33 | } |
---|
34 | |
---|
35 | if(this.domNode !== frag){ |
---|
36 | this.domNode.parentNode.replaceChild(frag, this.domNode); |
---|
37 | this.domNode = frag; |
---|
38 | } |
---|
39 | } |
---|
40 | }); |
---|
41 | return dojox.dtl.render.dom; |
---|
42 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.