Note that there are some explanatory texts on larger screens.

plurals
  1. PODojo Beginner: Hows do I make a custom Widget using _DomTemplated without getting a render error?
    primarykey
    data
    text
    <p>I am writing a custom Dojo Widget that uses the dojox.dtl._DomTemplated for DTL (Django Template Language) using the example <a href="http://view-source%3ahttp://archive.dojotoolkit.org/nightly/dojotoolkit/dojox/dtl/demos/demo_DomTemplated_amd.html" rel="nofollow">found here</a>. Basically, I am looking to have a widget that will either display or not display a set of buttons/links depending on the values set on the Widget. However, when I try to run my custom component, I get some strange pukage:</p> <blockquote> <p>You cannot use the Render object without specifying where you want to render it</p> </blockquote> <p>Which is occurring on line 3648 of <a href="http://ajax.googleapis.com/ajax/libs/dojo/1.7.1/dojo/dojo.js.uncompressed.js" rel="nofollow">dojo.js.uncompressed.js</a>.</p> <p>My Widget is pretty simple, and I have tried using an external template file and defining the templateString directly in the Widget JS file.</p> <p>Here is the widget code, as I currently have it: // img.ArtThumbnailWidget dojo.provide("img.ArtThumbnailWidget");</p> <pre><code>// Create the widget require([ "dojo/_base/declare", "dijit/_WidgetBase", "dojox/dtl/_DomTemplated", "dojo/text!img/ArtThumbnailWidget/templates/ArtThumbnailWidget.html", "dojo/parser", "dojox/dtl/tag/logic" ], function(declare, _WidgetBase, _DomTemplated, template) { dojo.declare("img.ArtThumbnailWidget",[dijit._WidgetBase, _DomTemplated], { /* Our properties will go here */ // Art JSON object, default is null art: null, // Viewer ID (the username of the person looking at this image), which will default to null viewerId: null, // maxSize is how large of an image to return. The back-end will resize the thumbnail accordingly maxSize: 100, // Our template - important! templateString: template, // A class to be applied to the root node in our template baseClass: "artThumbnailWidget", _dijitTemplateCompat: true, widgetsInTemplate: true, /* This is called once the DOM structure is ready, but before anything is shown */ postCreate: function() { // Get a DOM node reference for the root of our widget var domNode = this.domNode; // Run any parent postCreate processes - can be done at any point this.inherited(arguments); }, /* This is called anytime the "art" attribute is set. Consider is a "setter" method */ _setArtAttr: function(av) { if (av != null) { // Save it on our widget instance - note that // we're using _set, to support anyone using // our widget's Watch functionality, to watch values change this._set("art", av); // Using our avatarNode attach point, set its src value this.thumbnailNode.src = av.url+"?maxSize="+this.maxSize; this.thumbnailNode.alt = av.title; } else { // We could have a default here...would be an error, since we // shouldn't be calling this without an art object } }, _setMaxSizeAttr: function(ms) { // Save it on our widget instance - note that // we're using _set, to support anyone using // our widget's Watch functionality, to watch values change this._set("maxSize", ms); this.thumbnailNode.width = ms; this.thumbnailNode.height = ms; }, }); // End of the widget }); </code></pre> <p>And here is the Template:</p> <pre><code>&lt;div dojoAttachPoint="containerNode"&gt; &lt;img class="${baseClass}Thumbnail" src="" alt="" data-dojo-attach-point="thumbnailNode" /&gt; &lt;% if viewerId == art|owner|name %&gt; &lt;p&gt;test&lt;/p&gt; &lt;% endif %&gt; &lt;/div&gt; </code></pre> <p>In addition to trying to define the template directly in the Widget JS code, I have also tried simplifying the template by removing all the DTL tags in it. The Widget works fine if I use the standard _TemplateMixin instead of dojox.dtl._DomTemplated, except that the DTL doesn't get rendered, its just displayed as text. I have also tried using the dojox.dtl._Templated, but I get the same error.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload