Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to write my widget without declaring it's code in dojo.ready
    primarykey
    data
    text
    <p>Using some tutorials I wrote simple widget but it causes error "declare customwidget.TestDijit: mixin #0 is unknown":</p> <p>//test.html</p> <pre><code>&lt;title&gt;Test&lt;/title&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js" djConfig="parseOnLoad:true"&gt; &lt;/script&gt; &lt;script type="text/javascript" src="Test.js"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("customwidget.TestWidget"); &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;div dojoType='customwidget.TestWidget'/&gt; &lt;/body&gt; </code></pre> <p>//test.js</p> <pre><code>dojo.provide('customwidget.TestDijit') dojo.require('dijit._Widget'); dojo.require('dijit._Templated'); dojo.require('dojo.caсhe'); dojo.declare("customwidget.TestDijit", [dijit._Widget, dijit._Templated], { //can't use dojo.caсhe('customwidget.template', 'testdijit.html') I don't know why templatePath : "", widgetsInTemplate : true, lang : 'EN', postCreate: function(args, frag) { this.inherited('postCreate', arguments); }, clickEvent : function() { alert("Button Click event"); } }); </code></pre> <p>//testdijit.html</p> <pre><code>&lt;div id="${id}"&gt; &lt;input dojoattachevent="onClick: clickEvent" dojotype="dijit.form.Button" label="Search" /&gt; &lt;/div&gt; </code></pre> <p>I found out that if I place all widget's code in the dojo.ready funciton, then it will work(thank to <a href="http://dojotoolkit.org/documentation/tutorials/1.6/templated/" rel="nofollow noreferrer">this article</a>). Of course, I don't want to locate all my js code in the ready function. In the mentioned article's code sample authors wrote <code>// Future tutorials will explain how to properly separate this out into its own file.</code> Do you know how to solve this problem?</p> <p>PS. Do you also know why I can't use dojo.cashe in the this js code?</p> <p>UPD: Problems with loading cross-domain resources. <a href="https://stackoverflow.com/questions/308036/loading-dojo-library-from-aol-and-widget-codes-from-local">here</a> is similar discussion but I couldn understand how to solve the problem. I can store dojo localy but in this case it couldn't find my TestWidget.js - I don't how I can specify the path to my scipts. If I do that using baseUrl it will say "Could not load 'dojo._base.lang'; last tried './_base/lang.js'".</p> <p>test/test.html</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;head&gt; &lt;title&gt;Test&lt;/title&gt; &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojo/resources/dojo.css"&gt; &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dijit/themes/claro/claro.css"&gt; &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/Grid.css"&gt; &lt;link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/dojo/1.6/dojox/grid/resources/claroGrid.css"&gt; &lt;link rel="stylesheet" href="css/layout.css"&gt; &lt;script src="http://ajax.googleapis.com/ajax/libs/dojo/1.6.0/dojo/dojo.xd.js" djConfig="parseOnLoad:true, baseUrl: './'"&gt; &lt;/script&gt; &lt;script type="text/javascript"&gt; dojo.require("customwidget.TestWidget"); &lt;/script&gt; &lt;/head&gt; &lt;body class="claro"&gt; &lt;div dojoType='js.Test'&gt; &lt;/div&gt; &lt;/body&gt; </code></pre> <p>test/customwidget/TestWidget.js</p> <pre><code>dojo.provide('customwidget.TestWidget') dojo.require('dijit._Widget'); dojo.require('dijit._Templated'); dojo.require("dijit.form.Button"); //dojo.require('dojo.cache'); dojo.declare("customwidget.TestWidget", [dijit._Widget, dijit._Templated], { templatePath : "",//dojo.cache('customwidget.template', 'testdijit.html'), widgetsInTemplate : true, lang : 'EN', postCreate: function(args, frag) { this.inherited('postCreate', arguments); }, clickEvent : function() { alert("Button Click event"); } }); </code></pre>
    singulars
    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.
 

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