Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit a148ce9

Browse files
committed
Merge pull request #198 from chlu/fix-alohaWidget
alohaWidget: Trigger change event whenever the editable is modified
2 parents 4da71f3 + 06a7f8b commit a148ce9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

dist/create.js

+11
Original file line numberDiff line numberDiff line change
@@ -3005,17 +3005,28 @@ window.midgardCreate.localize = function (id, language) {
30053005
}
30063006
editable.vieEntity = options.entity;
30073007

3008+
var checkEditableChanged;
3009+
3010+
function activeEditableChanged() {
3011+
if (Aloha.activeEditable.isModified()) {
3012+
options.changed(Aloha.activeEditable.getContents());
3013+
Aloha.activeEditable.setUnmodified();
3014+
}
3015+
}
3016+
30083017
// Subscribe to activation and deactivation events
30093018
Aloha.bind('aloha-editable-activated', function (event, data) {
30103019
if (data.editable !== editable) {
30113020
return;
30123021
}
3022+
checkEditableChanged = window.setInterval(activeEditableChanged, 500);
30133023
options.activated();
30143024
});
30153025
Aloha.bind('aloha-editable-deactivated', function (event, data) {
30163026
if (data.editable !== editable) {
30173027
return;
30183028
}
3029+
window.clearInterval(checkEditableChanged);
30193030
options.deactivated();
30203031
});
30213032

src/editingWidgets/jquery.Midgard.midgardEditableEditorAloha.js

+11
Original file line numberDiff line numberDiff line change
@@ -36,17 +36,28 @@
3636
}
3737
editable.vieEntity = options.entity;
3838

39+
var checkEditableChanged;
40+
41+
function activeEditableChanged() {
42+
if (Aloha.activeEditable.isModified()) {
43+
options.changed(Aloha.activeEditable.getContents());
44+
Aloha.activeEditable.setUnmodified();
45+
}
46+
}
47+
3948
// Subscribe to activation and deactivation events
4049
Aloha.bind('aloha-editable-activated', function (event, data) {
4150
if (data.editable !== editable) {
4251
return;
4352
}
53+
checkEditableChanged = window.setInterval(activeEditableChanged, 500);
4454
options.activated();
4555
});
4656
Aloha.bind('aloha-editable-deactivated', function (event, data) {
4757
if (data.editable !== editable) {
4858
return;
4959
}
60+
window.clearInterval(checkEditableChanged);
5061
options.deactivated();
5162
});
5263

0 commit comments

Comments
 (0)