WidgetRepeater.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  1. if (!dojo._hasResource["dojox.wire.demos.WidgetRepeater"]) { // _hasResource
  2. // checks added
  3. // by build. Do
  4. // not use
  5. // _hasResource
  6. // directly in
  7. // your code.
  8. dojo._hasResource["dojox.wire.demos.WidgetRepeater"] = true;
  9. dojo.provide("dojox.wire.demos.WidgetRepeater")
  10. dojo.require("dojo.parser");
  11. dojo.require("dijit._Widget");
  12. dojo.require("dijit._Templated");
  13. dojo.require("dijit._Container");
  14. dojo.declare("dojox.wire.demos.WidgetRepeater", [dijit._Widget,
  15. dijit._Templated, dijit._Container], {
  16. // summary:
  17. // Simple widget that does generation of widgets repetatively,
  18. // based on calls to
  19. // the createNew function and contains them as child widgets.
  20. templateString : "<div class='WidgetRepeater' dojoAttachPoint='repeaterNode'></div>",
  21. widget : null,
  22. repeater : null,
  23. createNew : function(obj) {
  24. // summary:
  25. // Function to handle the creation of a new widget and
  26. // appending it into the widget tree.
  27. // obj:
  28. // The parameters to pass to the widget.
  29. try {
  30. if (dojo.isString(this.widget)) {
  31. dojo.require(this.widget);
  32. this.widget = dojo.getObject(this.widget);
  33. }
  34. this.addChild(new this.widget(obj));
  35. this.repeaterNode.appendChild(document
  36. .createElement("br"));
  37. } catch (e) {
  38. console.debug(e);
  39. }
  40. }
  41. });
  42. }