С небольшим форматированием вы можете легко увидеть разницу.
Один раз вы вызываете then
для результата $translate
, а другой раз вы вызываете then
для определения функции.
$row.find('.gridCellDetailAction')
.each(
(i, elem) => {
$translate(
'Grid.Show' + $(elem).attr('data-title') + 's'
)
.then(
trans => $(elem).attr('title', trans)
)
}
);
$row.find('.gridCellDetailAction')
.each(
function (i, elem) {
$translate('Grid.Show' + $(elem).attr('data-title') + 's')
}// <-- The error is here
.then(
function (trans) {
$(elem).attr('title', trans)
}
)
);
Это было бы правильно:
$row.find('.gridCellDetailAction')
.each(
function (i, elem) {
$translate('Grid.Show' + $(elem).attr('data-title') + 's')
.then( //Now then is called on the result of $translate
function (trans) {
$(elem).attr('title', trans)
}
)
}
);