fixed htmlarea not returning any content caused by prefixed DOM id, now all DOMwidgets have their DOM id available via this.dom_id set via this.set_id()

This commit is contained in:
Ralf Becker 2013-08-23 14:10:37 +00:00
parent 3bbfb8574b
commit f4e1db3a68
5 changed files with 28 additions and 28 deletions

View File

@ -286,13 +286,14 @@ var et2_DOMWidget = et2_widget.extend(et2_IDOMNode,
set_id: function(_value) {
this.id = _value;
this.dom_id = _value ? this.getInstanceManager().uniqueId+'_'+_value : _value;
var node = this.getDOMNode(this);
if (node)
{
if (_value != "")
{
node.setAttribute("id", this.getInstanceManager().uniqueId+'_'+this.id);
node.setAttribute("id", this.dom_id);
}
else
{

View File

@ -142,6 +142,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
set_id: function(_value) {
this.id = _value;
this.dom_id = _value ? this.getInstanceManager().uniqueId+'_'+this.id : _value;
// Set the id of the _input_ node (in contrast to the default
// implementation, which sets the base node)
@ -151,7 +152,7 @@ var et2_inputWidget = et2_valueWidget.extend([et2_IInput,et2_ISubmitListener],
// Unique ID to prevent DOM collisions across multiple templates
if (_value != "")
{
node.setAttribute("id", this.getInstanceManager().uniqueId+'_'+this.id);
node.setAttribute("id", this.dom_id);
node.setAttribute("name", _value);
}
else

View File

@ -212,9 +212,9 @@ var et2_dropdown_button = et2_inputWidget.extend(
// Update internal IDs - not really needed since we refer by internal
// javascript reference, but good to keep up to date
this.internal_ids = {
div: this.getInstanceManager().uniqueId+'_'+this.id + "_wrapper",
button: this.getInstanceManager().uniqueId+'_'+this.id,
menu: this.getInstanceManager().uniqueId+'_'+this.id + "_menu"
div: this.dom_id + "_wrapper",
button: this.dom_id,
menu: this.dom_id + "_menu"
};
for(var key in this.internal_ids)
{

View File

@ -82,7 +82,6 @@ var et2_htmlarea = et2_inputWidget.extend(
// Allow no child widgets
this.supportedWidgetClasses = [];
this.htmlNode = $j(document.createElement("textarea"))
.attr('id', this.id)
.css('height', this.options.height)
.addClass('et2_textbox_ro');
this.setDOMNode(this.htmlNode[0]);
@ -111,21 +110,21 @@ var et2_htmlarea = et2_inputWidget.extend(
var ckeditor;
try
{
CKEDITOR.replace(this.id,jQuery.extend({},this.options.config,this.options));
ckeditor = CKEDITOR.instances[this.id];
CKEDITOR.replace(this.dom_id,jQuery.extend({},this.options.config,this.options));
ckeditor = CKEDITOR.instances[this.dom_id];
ckeditor.setData(self.value);
delete self.value;
}
catch (e)
{
if(CKEDITOR.instances[this.id])
if(CKEDITOR.instances[this.dom_id])
{
CKEDITOR.instances[this.id].destroy();
CKEDITOR.instances[this.dom_id].destroy();
}
if(this.htmlNode.ckeditor)
{
CKEDITOR.replace(this.id,this.options.config);
ckeditor = CKEDITOR.instances[this.id];
CKEDITOR.replace(this.dom_id,this.options.config);
ckeditor = CKEDITOR.instances[this.dom_id];
ckeditor.setData(self.value);
delete self.value;
}
@ -136,8 +135,8 @@ var et2_htmlarea = et2_inputWidget.extend(
try
{
//this.htmlNode.ckeditorGet().destroy(true);
ckeditor = CKEDITOR.instances[this.id];
ckeditor.destroy(true);
var ckeditor = CKEDITOR.instances[this.dom_id];
if (ckeditor) ckeditor.destroy(true);
}
catch (e)
{
@ -146,15 +145,18 @@ var et2_htmlarea = et2_inputWidget.extend(
}
},
set_value: function(_value) {
if(this.htmlNode.is('textarea'))
{
this.htmlNode.val(_value);
return;
}
try {
//this.htmlNode.ckeditorGet().setData(_value);
ckeditor = CKEDITOR.instances[this.id];
var ckeditor = CKEDITOR.instances[this.dom_id];
if (ckeditor)
{
ckeditor.setData(_value);
}
else
{
this.htmlNode.val(_value);
this.value = _value;
}
} catch (e) {
// CK editor not ready - callback will do it
this.value = _value;
@ -162,15 +164,11 @@ var et2_htmlarea = et2_inputWidget.extend(
},
getValue: function() {
if(this.htmlNode.is('textarea'))
{
return this.htmlNode.val();
}
try
{
//return this.htmlNode.ckeditorGet().getData();
ckeditor = CKEDITOR.instances[this.id];
return ckeditor.getData();
var ckeditor = CKEDITOR.instances[this.dom_id];
return ckeditor ? ckeditor.getData() : this.htmlNode.val();
}
catch (e)
{

View File

@ -279,7 +279,7 @@ var et2_selectbox = et2_inputWidget.extend(
// Already in header
if(_label == this.options.empty_label) return;
var opt_id = this.getInstanceManager().uniqueId+'_'+ this.id + "_opt_" + _value;
var opt_id = this.dom_id + "_opt_" + _value;
var label = jQuery(document.createElement("label"))
.attr("for", opt_id)
.hover(