Answer the question
In order to leave comments, you need to log in
How to change the value of a global variable in callbacks?
....
var idResource = 1;
$R('#content', {
autosave: '/assets/tmp/redactor/add/autosave.php',
autosaveData: {
id: idResource,
elements: '#pagetitle'
},
callbacks: {
autosave: function(name, data, response)
{
idResource = response; // не меняется значение переменной при повторном autosave .
...
Answer the question
In order to leave comments, you need to log in
"else" always refers to the same branch. If you wrote "else" after the last branch, then the second branch will also apply to it.
When designing mutually exclusive options (for example, when a part cannot be both first-class and defective at the same time), it is recommended to use the following design:
if (clause1) {
action1;
} else if (clause2) {
action2;
} else {
action3;
}
window.idResource = response;
console.log('window.idResource = ', window.idResource);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question