two different editors
two different editors
Hi
from the server I get a config that should show two different editors templates. Depending on the config another template is
displayed.function template1() {
var html = <div id="customForm1">
<fieldset class="firma">
.....
</fieldset>
</div>
$("#templates").html("");
$("#templates").append(html);
editor.template('#customForm1');
}
displayed.function template2() {
var html = <div id="customForm2">
<fieldset class="name">
.....
</fieldset>
</div>
$("#templates").html("");
$("#templates").append(html);
editor.template('#customForm2');
}
editor.on( 'open', function ( e, o, action) {
var firma = this.field( 'firma' );
if (firma.val().length > 0){
template1()
} else {
template2()
}
It does not work like that. Can not I assign an HTML template at runtime?
How would I have to change that to work correctly?
THANK YOU
Ciao
Replies
You can, but its too late by the time the
open
is called. UsepreOpen
.Allan
That just does not want to work. The template is not displayed with Open or preOpen.
The template is displayed in the editor. It takes two clicks. The first click displays the wrong template. Another click then displays the correct template. Does the old template have to be deleted? Will not this be overwritten? Or does it have to be reinitialized?
Sorry! I'd completely lost track of this thread!
Looking at the code sequence a bit closer
preOpen
is actually too late for the template as well. However, what we can do is trigger a forced redraw of the new template through use of theorder()
method:Its a little bit of a hack and I feel there should probably be a better way to do this, but that way will work in the current release.
Allan