Skip to content

Commit

Permalink
Fix #3161 Send event only if listener called for this instance
Browse files Browse the repository at this point in the history
  • Loading branch information
avernet committed Apr 17, 2017
1 parent 2bd8cca commit b626f82
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions src/main/assets/xbl/orbeon/tinymce/tinymce.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,9 @@
TINYMCE_CUSTOM_CONFIG :
YAHOO.xbl.fr.Tinymce.DefaultConfig;
// Our onchange listener, not using onChange as it doesn't work with the fullscreen plugin
config.onchange_callback = _.bind(this.clientToServer, this);
config.onchange_callback = _.bind(this._clientToServer, this);
return config;
}).call(this);
tinyMceConfig.onchange_callback = _.bind(this.clientToServer, this);
var tinyMceDiv = YAHOO.util.Dom.getElementsByClassName('xbl-fr-tinymce-div', null, this.container)[0];
var tabindex = $(tinyMceDiv).attr('tabindex');
this.myEditor = new tinymce.Editor(tinyMceDiv.id, tinyMceConfig);
Expand Down Expand Up @@ -83,16 +82,19 @@
},

// Send value in MCE to server
clientToServer: function() {
_clientToServer: function() {
var editor = arguments[0];
var content = editor.getContent();
// Workaround to TinyMCE issue, see https://twitter.com/avernet/status/579031182605750272
if (content == '<div>\xa0</div>') content = '';
ORBEON.xforms.Document.dispatchEvent({
targetId: this.container.id,
eventName: 'fr-set-client-value',
properties: { 'fr-value': content }
});
// Check the change event is for the editor corresponding to this component instance
if (editor.id == this.myEditor.id) {
var content = editor.getContent();
// Workaround to TinyMCE issue, see https://twitter.com/avernet/status/579031182605750272
if (content == '<div>\xa0</div>') content = '';
ORBEON.xforms.Document.dispatchEvent({
targetId: this.container.id,
eventName: 'fr-set-client-value',
properties: { 'fr-value': content }
});
}
},

// TinyMCE got the focus
Expand Down

0 comments on commit b626f82

Please sign in to comment.