Reputation: 53
I have laravel traits that convert numbers to money-currency format. If I want to use it on blade template I only call it like
<td class="text-center"> @money($repayment->admnin) </td>
My problem is, I want to use it inside the tag, how do I suppose to use that @money traits?
here's my code example
$.ajax({
method: 'get',
url: `${url}/${due_date}`,
}).done((data) => {
let paymentTotal = 10000;
let { totalInterest, totalPrincipal, paymentTotal,
due_date, loanNumber, borrowerFullname } = data;
$('#simulation-table').show();
$('#totalbayar').append(
// I want to use that @money here, I tried like this below
`@money(${paymentTotal})`
)
}).fail((err) => {
console.log(err, 'error coy');
});
Upvotes: 0
Views: 42
Reputation: 241
you can assign an id to <td>
like
<td id="xyz" class="text-center"> @money($repayment->admnin) </td>
and in Ajax you can get the value by using jquery or javascript :
$.ajax({
method: 'get',
url: `${url}/${due_date}`,
}).done((data) => {
let paymentTotal = 10000;
let pay = $('xyz').val() // for jquery
let pay = document.getElementById("xyz").value // for javascript
let { totalInterest, totalPrincipal, paymentTotal,
due_date, loanNumber, borrowerFullname } = data;
$('#simulation-table').show();
// and you can use the value like this
$('#totalbayar').append(pay))
}).fail((err) => {
console.log(err, 'error coy');
});
Upvotes: 1