"initEdit" versus "open" with "action === 'edit'"
"initEdit" versus "open" with "action === 'edit'"
Hi Allan,
I have replaced all of my "initEdit" Editor events with "open" events checking for "action === 'edit'".
I noticed that the initEdit events were only triggered when the form was opened for the first time. When I edited a record, closed the form and reopened it again, initEdit wasn't triggered. I needed a page refresh for it to work again. That was an issue. Is this as designed? Or is this a bug?
The open event works fine and doesn't need a page refresh to work when I open, close and reopen the form.
Here is the code that I moved from initEdit to open:
.on('open', function(e, mode, action) {
$('.DTE_Form_Info').addClass("text-warning");
if (action === 'edit') {
this.message( function () {
return 'If you change this entry all of your corresponding\n\
approval requests will be deleted!';
})
this.disable( [ 'contract.govdept_id',
'contract.instrument',
'contract.type' ] );
//in case there already is a derivative you can only change to multiple derivatives
//because you shouldn't delete a component only add components
if (this.val('contract.derivative') >= 'A') {
var i = 0;
while (derivativeOptions[i]) {
if (derivativeOptions[i].value === this.val('contract.derivative')) {
this.field('contract.derivative')
.update([ derivativeOptions[i] ], false);
}
i++;
}
if (this.val('contract.derivative') !== 'X5') {
this.field('contract.derivative')
.update(derivativeOptionsMultipleOnly, true);
}
} else {
var opts = derivativeOptions;
if ( this.val('contract.type') === 'F' ) { //if it is fixed rate
opts = derivativeOptionsNoCapFloorCollar;
} else {
if ( this.val('contract.type').substring(0,1) === 'V' ) { //if it is variable rate
if (val >= 'V1') { //if it includes cap floor collar
opts = derivativeOptionsNoCapFloorCollarFRA;
} else { //if it does not include a derivative
opts = derivativeOptionsNoFRA;
}
}
}
this.field('contract.derivative').update(opts, false);
}
}
This question has accepted answers - jump to:
Answers
It should always be triggered. Could you give me a link to a page showing the issue so I can check it out?
Allan
Sorry, no. I removed all of them and replaced them with open events. Seems like initEdit is redundant for my purposes. Just wanted to let you know about the issue ...
I think there is something else going on. If you load up this example and run the following in the console:
Then every time you trigger an edit it will correctly show the console message as expected.
Allan
yes, it is a bit strange, isn't it?