Issue with ComboBox in custom widget

564
3
Jump to solution
03-27-2019 03:05 AM
OscarDiago_Alonso
New Contributor III

Good morning.

I'm stuck trying to do simple widget with a CombBox.

My HTML look like this:

<div>
    <div data-dojo-attach-point="selectTipo"></div>
</div>

My Widget.js is currently just this:

define(['dojo/_base/declare', 'jimu/BaseWidget', 'dijit/form/Select', 'dojo/data/ObjectStore', 'dojo/store/Memory', 'dojo/domReady!'],
  function(declare, BaseWidget) {
    return declare([BaseWidget], {
      baseClass: 'jimu-widget-widgetprueba',

      startup: function() {
       this.inherited(arguments);

       var store = new Memory({
				data: [
				  { id: "foo", label: "Foo" },
				  { id: "bar", label: "Bar" }
				]
			  });

		  var os = new ObjectStore({ objectStore: store });

		  var s = new Select({
			store: os
		  }, this.selectTipo);
		  s.startup();
      }
    });
  });

But when I run this in the demo, I get this error.

ReferenceError: Memory is not defined

I have added the 'dojo/store/Memory', so I don't understand what the problem is!

Thanks for any help!

Tags (1)
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

You have to include the arguments in your function that refer to the modules you're adding in the define

define(['dojo/_base/declare', 'jimu/BaseWidget', 'dijit/form/Select', 'dojo/data/ObjectStore', 'dojo/store/Memory', 'dojo/domReady!'],
  function(declare, BaseWidget, Select, ObjectStore, Memory) {

View solution in original post

3 Replies
KenBuja
MVP Esteemed Contributor

You have to include the arguments in your function that refer to the modules you're adding in the define

define(['dojo/_base/declare', 'jimu/BaseWidget', 'dijit/form/Select', 'dojo/data/ObjectStore', 'dojo/store/Memory', 'dojo/domReady!'],
  function(declare, BaseWidget, Select, ObjectStore, Memory) {
OscarDiago_Alonso
New Contributor III

Thanks! That worked!

0 Kudos
RobertScheitlin__GISP
MVP Emeritus

Also to add to what Ken has said if you are going to include widget in your template then you need to have the mixin added as well:

define(['dojo/_base/declare', 'jimu/BaseWidget', 'dijit/_WidgetsInTemplateMixin', 'dijit/form/Select', 'dojo/data/ObjectStore', 'dojo/store/Memory', 'dojo/domReady!'],
  function(declare, BaseWidget, _WidgetsInTemplateMixin, Select, ObjectStore, Mamory) {
    return declare([BaseWidget, _WidgetsInTemplateMixin], {