Quantcast
Channel: Customized Commerce 13 and earlier versions
Viewing all articles
Browse latest Browse all 9642

Dojo component Template.html not loading

$
0
0

I have a custom dojo component with a Template.html file. It seems to be trying to load the Template file from /Episerver/Shell rather than from my component location.

Files are in wwwroot as follows:

DateTextBoxUtc.js

define('Epik/Editors/DateTextBoxUtc/DateTextBoxUtc', ['dojo/_base/array','dojo/_base/connect','dojo/_base/declare','dojo/_base/lang','dijit/_CssStateMixin','dijit/_Widget','dijit/_TemplatedMixin','dijit/_WidgetsInTemplateMixin','dijit/dijit', // loads the optimized dijit layer'dijit/Calendar','dijit/form/DateTextBox','dijit/form/ValidationTextBox','dojo/text!./Template.html','epi/epi'
	],
	function(
		array,
		connect,
		declare,
		lang,
		_CssStateMixin,
		_Widget,
		_TemplatedMixin,
		_WidgetsInTemplateMixin,
		dijit,
		Calendar,
		DateTextBox,
		TextBox,
		template,
		epi
	) {
		return declare([_Widget, _TemplatedMixin, _WidgetsInTemplateMixin, _CssStateMixin],
			{
				templateString: template,
				postCreate: function() {
					this.set('value', this.value);
					this.dateInputWidgetTextbox.set('value', this.value);
					// Init textarea and bind event
					this.connect(this.dateInputWidgetTextbox, 'onClick', this._onbutton);
					this.connect(this.dateInputWidgetCalendar, 'onValueSelected', this._onCalendar);
					this.connect(this.dateInputWidgetTextbox, 'onKeyPress', this._onTextAreaPress);
					this.connect(this.dateInputWidgetTextbox, 'onBlur', this._onChange);
				},
				_onIntermediateChange: function(event) {
					if (this.intermediateChanges) {
						this._set('value', event.target.value);
						this.onChange(this.value);
					}
				},
				// Setter for value property
				_setValueAttr: function(value) {
					this.dateInputWidgetTextbox.set('value', value);
					this._set('value', value);
				},
				// Setter for intermediateChanges
				_setIntermediateChangesAttr: function(value) {
					this.dateInputWidgetTextbox.set('intermediateChanges', value);
					this._set('intermediateChanges', value);
				},
				// Event handler for textarea
				_onbutton: function() {
					this.dateInputWidgetCalendar.set('style', 'display:block!important');
				},
				_onCalendar: function(date) {
					var dd = date.getDate() + '/' + (date.getMonth() + 1) + '/' + date.getFullYear();
					this.dateInputWidgetTextbox.setValue(dd);
					this._updateValue(this.dateInputWidgetTextbox.value);
					this.dateInputWidgetCalendar.set('style', 'display:none!important');
				},
				_onTextAreaPress: function() {
					this._set('value', this.dateInputWidgetTextbox.value);
					this._updateValue(this.dateInputWidgetTextbox.value);
					this.dateInputWidgetCalendar.set('style', 'display:block!important');
				},
				_onChange: function() {
					this._set('value', this.dateInputWidgetTextbox.value);
					this._updateValue(this.dateInputWidgetTextbox.value);
				},
				onChange: function(value) {
				},
				// updates the value and tells epi to save
				_updateValue: function(value) {
					if (epi.areEqual(this.value, value)) {
						return;
					}
					this._set('value', value);
					this.onChange(value);
				}
			});
	});

module.config

<?xml version="1.0" encoding="utf-8" ?><module><dojo><paths><add name="Epik" path="Scripts" /></paths></dojo><clientResources><add name="epi-cms.widgets.base" path="Scripts/Editors/DateTextBoxUtc/Template.html" /><add name="epi-cms.widgets.base" path="Scripts/Editors/DateTextBoxUtc/DateTextBoxUtc.js" resourceType="Script" /></clientResources><clientModule><moduleDependencies><add dependency="Shell" type="RunAfter" /><add dependency="CMS" type="RunAfter" /></moduleDependencies></clientModule></module>

I'm referencing the Template.html in the js file by using "'dojo/text!./Template.html" as it is in the same folder. Is this not the correct way to be referencing the template file?


Viewing all articles
Browse latest Browse all 9642

Trending Articles