Custom property editor - That's not really an editor!
Hi All,
So, I'm trying to build what is effectively a custom property editor that doesn't save it's information in the related document.
In simple, I have a document type "My Doc Type".
It has a tab "Announcements"
On said tab, I am putting a custom property editor. The editor is available once the document is saved. It has several fields (title [text], message [rte] and duration [ numeric]) and a custom "post" button.
The post button sends the information along with the id of the page to a custom api controller (well it will when I get to that last stage).
However, after the post event has run, I want to reset the fields back to default values.
This is working for the title filed and the duration filed, however the message filed isn't resetting in the RTE on screen.
I don't want the editor to have to "save" the page each time in order to post the announcement as this are short lived items and aren't document types. (I could do the whole thing with document types, but I think that would be inefficient).
Does anyone have any ideas/suggestions as to what I might be doing wrong/am missing?
For anyone that is interested, the way I've had to go about this is (in my opinion) a bit of a hack. Saying that it is similar to how the RTE PE works in the core.
Step 1)
set an alias in the RTE configuration:
I did the following to make it unique:
var d = new Date();
var n = d.getTime();
var rteAlias = 'announcement_' + n;
Step 2)
In my post announcement method where I want to do the reset the value I've had to do the following:
if (tinyMCE !== undefined) {
tinyMCE.editors.forEach(function(item, index) {
if (item.id.startsWith(rteAlias)) {
item.setContent('');
item.fire('LoadContent', null);
}
});
}
Effectively, check if tinyMCE has been loaded into the page. If it has, for each editor that exists in tinyMCE, check to see if its id starts with your alias (hence the reason for making it unique). If it does, call setConent and fire the LoadContent event.
I've had to take this approach as I couldn't find a way to obtain the id of the RTE that Umbraco generates.
Custom property editor - That's not really an editor!
Hi All,
So, I'm trying to build what is effectively a custom property editor that doesn't save it's information in the related document.
In simple, I have a document type "My Doc Type". It has a tab "Announcements"
On said tab, I am putting a custom property editor. The editor is available once the document is saved. It has several fields (title [text], message [rte] and duration [ numeric]) and a custom "post" button.
The post button sends the information along with the id of the page to a custom api controller (well it will when I get to that last stage).
However, after the post event has run, I want to reset the fields back to default values.
This is working for the title filed and the duration filed, however the message filed isn't resetting in the RTE on screen.
My editor view:
My controller code:
My reset code exists in this function: $scope.postAnnouncement
Yet, for some reason it doesn't impact the RTE. I've tried adding a watch a watch as per information on : http://tooorangey.co.uk/posts/editor-notes-for-umbraco-7/ and http://24days.in/umbraco/2014/umbraco-angular-tips/ with no effect.
I don't want the editor to have to "save" the page each time in order to post the announcement as this are short lived items and aren't document types. (I could do the whole thing with document types, but I think that would be inefficient).
Does anyone have any ideas/suggestions as to what I might be doing wrong/am missing?
Nik
For anyone that is interested, the way I've had to go about this is (in my opinion) a bit of a hack. Saying that it is similar to how the RTE PE works in the core.
Step 1)
set an alias in the RTE configuration:
I did the following to make it unique:
Step 2)
In my post announcement method where I want to do the reset the value I've had to do the following:
Effectively, check if tinyMCE has been loaded into the page. If it has, for each editor that exists in tinyMCE, check to see if its id starts with your alias (hence the reason for making it unique). If it does, call setConent and fire the LoadContent event.
I've had to take this approach as I couldn't find a way to obtain the id of the RTE that Umbraco generates.
is working on a reply...