简体   繁体   中英

Laravel - javascript issue with pound and euro

I have this code:

$(".range").ionRangeSlider({
    min: '{{$article->lowest_bid}}',
    max: '{{$article->price}}',
    from: obj.price,
    step: 0.1,
    max_postfix: ' (usual rate)',
    prefix: '{{$article->cur}}',
    onChange: function (data) {
        $('.price').val(data.from);

    },
    onFinish: function (data) {
      var curr = '{{$article->cur}}';
      $('.runload').text('PLACE BID ' +curr+(data.from).toFixed(2));
    }
});

So this function work good and show sign £ and other ... but onFinish function there just I get 'PLACE BID £33.00'

Why {{$article->cur}} from database dont work on my onFinish ? How to solve it?

on line: prefix: '{{$article->cur}}', work good and show sign but onFinish dont work

The pound and euro signs are being rendered as their HTML entities , ie the escaped format so they don't interfere with code.

To display them correctly, you could replace the .text() call with .html() :

onFinish: function (data) {
  var curr = '{{$article->cur}}';
  $('.runload').html('PLACE BID ' +curr+(data.from).toFixed(2));
}

This will treat the data.from as HTML, so will render the HTML entities correctly.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM