asi hej
asi hej

Reputation: 343

Cannot access object on IOS Safari, but works on Desktop Chrome

I've created a JavaScript Filter object and including it in laravel blade.php file. When trying to access the object on windows 10 Chrome it works, but on IOS Safari or Chrome i still get undefined.

var filter = new Filter();

var handlesSlider = document.getElementById('filter-price');

var min = parseInt(handlesSlider.dataset.min);
var max = parseInt(handlesSlider.dataset.max) + 1;

noUiSlider.create(handlesSlider, {
    start: [min, max],
    tooltips: true,
    connect: true,
    margin: 5,
    range: {
        'min': min,
        'max': max
    },
    format: {
        // 'to' the formatted value. Receives a number.
        to: function (value) {
            return `${Math.round(value)}€`
        },
        // 'from' the formatted value.
        // Receives a string, should return a number.
        from: function (value) {
            return Number(value.replace(',-', ''));
        }
    }
});


var json = {!! $json !!};
handlesSlider.noUiSlider.on('change.one', function (e) {  

    const min = e[0].replace("€", "");
    const max = e[1].replace("€", "");   

    var filteredProducts = json
    .filter(product =>         
        parseInt(product.price) >= min && 
        parseInt(product.price) <= max);

    filter.render(document.querySelector("{{ $selector }}"), filteredProducts);        
});
filter.render(document.querySelector("{{ $selector }}"), json);       
alert(filter);

And Including it in another file as:

 @include('components.filter', ['min' => $min, 'max' => $max, 'json' => 
 $products->toJson(), 'selector' => '.product-list__products'])

On desktop i get clear alert object object, but on mobile undefined or no alert at all.

Upvotes: 3

Views: 527

Answers (1)

asi hej
asi hej

Reputation: 343

The solution was that, ios 13.1.3 cannot understand JS Arrow functions and also modules.

Upvotes: 1

Related Questions