November Happy Hour will be moved to Thursday December 5th.
Hi,
I've created my own widget
define([ "dojo/_base/declare", "dojo/_base/connect", "dojo/_base/lang", "dojo/query", "dojo/_base/array", "dojo/_base/window", "epi-cms/contentediting/editors/SelectionEditor", "dijit/_Widget", "dijit/_TemplatedMixin", "dijit/_WidgetsInTemplateMixin", "dojo/text!./Templates/TwoAreas.html" ], function (declare, connect, lang, query, array, window, selectionEditor, _Widget, _TemplatedMixin, _WidgetsInTemplateMixin, template) { return declare("epi-gadgets.MultiSelect.TwoAreas", [_Widget, _TemplatedMixin, _WidgetsInTemplateMixin], { templateString: template, items: null, initialValue: null, //1 constructor: function (value) { //this.inherited(arguments); this.items = value.selections; this.initialValue = value.value; }, readOnlyAttr: false, //2 _setValueAttr: function(value) { this.setValue(value); }, _setReadOnlyAttr: function(value) { this._set("readOnly", value); this.readOnlyAttr = value; }, //startup: function() { // this.postCreate(); //}, //3 postCreate: function () { // call base implementation this.inherited(arguments); for (var i = 0; i < this.items.length; i++) { if (this.initialValue && this.initialValue.includes(this.items[i].value)) { this._addOption(this.items[i].value, this.items[i].text, this.selectedOptions); } else { this._addOption(this.items[i].value, this.items[i].text, this.availableOptions); } } this.selectButton.setDisabled(this.readOnlyAttr) this.removeButton.setDisabled(this.readOnlyAttr) this.availableOptions.setDisabled(this.readOnlyAttr) this.selectedOptions.setDisabled(this.readOnlyAttr) }, selectionChanged: function (object) { var value = this._getValue(); this._set("value", value); }, addOptions: function (value) { var selectedOptions = this._getSelectedValues(this.availableOptions); for (var i = 0; i < selectedOptions.length; i++) { this._addOption(selectedOptions[i].value, selectedOptions[i].innerHTML, this.selectedOptions); this.availableOptions.containerNode.removeChild(selectedOptions[i]); } this.selectionChanged(); }, removeOptions: function (value) { var selectedOptions = this._getSelectedValues(this.selectedOptions); for (var i = 0; i < selectedOptions.length; i++) { this._addOption(selectedOptions[i].value, selectedOptions[i].innerHTML, this.availableOptions); this.selectedOptions.containerNode.removeChild(selectedOptions[i]); } this.selectionChanged(); }, _addOption: function (value, text, multiSelect) { var option = window.doc.createElement('option'); option.innerHTML = text; option.value = value; multiSelect.domNode.appendChild(option); }, _getValue: function () { var result = ""; var addedValues = []; var selectedOptions = query("option", this.selectedOptions.containerNode); for (var i = 0; i < selectedOptions.length; i++) { if (array.indexOf(addedValues, selectedOptions[i].value) != -1) { continue; } if (i != 0) { result = result + ","; } result = result + selectedOptions[i].value; addedValues[addedValues.length] = selectedOptions[i].value; } return result; }, _getSelectedValues: function (multiSelect) { var result = []; var processedValues = []; var selectedOptions = query("option", multiSelect.containerNode); for (var i = 0; i < selectedOptions.length; i++) { if (selectedOptions[i].selected) { if (array.indexOf(processedValues, selectedOptions[i].value) != -1) { continue; } var selectedOptionsByValue = query("option[value=\"" + selectedOptions[i].value + "\"]", multiSelect.containerNode); for (var j = 0; j < selectedOptionsByValue.length; j++) { result[result.length] = selectedOptionsByValue[j]; } processedValues[processedValues.length] = selectedOptions[i].value; } } return result; }, setValue: function (value) { if (!value) { return; } var options = value.split(","); for (var i = 0; i < options.length; i++) { var optionsWithValue = query("option[value=\"" + options[i] + "\"]", this.availableOptions.containerNode); for (var j = 0; j < optionsWithValue.length; j++) { this._addOption(optionsWithValue[j].value, optionsWithValue[j].innerHTML, this.selectedOptions); this.availableOptions.containerNode.removeChild(optionsWithValue[j]); } } } }); });
I am using 'all properties view' as default for all pages and blocks. Application uses EPiServer 7.18
If I select page with my widget than episerver doesn't open all properties view but switch button set to 'all properties view'.
If I change view to 'On-Page editing' and than return to 'All properties' episerver shows properties and my widget.
During debuging I've find out that episerver always calls constructor from my widget after open page but doesn't call postCreate method
I hope someone faced with similar issue
Hi,
I've created my own widget
I am using 'all properties view' as default for all pages and blocks. Application uses EPiServer 7.18
If I select page with my widget than episerver doesn't open all properties view but switch button set to 'all properties view'.
If I change view to 'On-Page editing' and than return to 'All properties' episerver shows properties and my widget.
During debuging I've find out that episerver always calls constructor from my widget after open page but doesn't call postCreate method
I hope someone faced with similar issue