11

I have to arrays (Name and State Array) and map them togther into one object with the attrbiutes name and state.

Array Name:

 ["Time", "Riskchanged", "Scope", "Risk4", "Test", "Test(2)"]

Array State:

 ["In Bearbeitung", "Abgeschlossen", "In Bearbeitung", "Abgeschlossen", "Geplant", "In Bearbeitung"]

Function:

this.testArr = this.riskNamesArr.map( (x, i) => {
    return {"name": x, "state": this.riskWorkflowStateArr[i]}        
});

This works perfect on all Desktop Browsers but unfortunately not on my iOS Safari Browser.. The mobile Browser just shows nothing if I add those lines..

So is there another approach to get the same result?

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
simplesystems
  • 839
  • 2
  • 14
  • 28
  • Have you tried using the anonymous function in place of the Arrow function expression, does iOS Safari support ES6? – David Thomas Jul 05 '16 at 12:59
  • Like @simplesystems says, it would be a good idea to [check the ES? compatibility here](https://kangax.github.io/compat-table/es6/). – David Gourde Jul 05 '16 at 13:04

3 Answers3

16

I think thats a problem with the arrow-function - thats ES6-style. Try using a simple function:

testArr = riskNamesArr.map( function(x, i){
    return {"name": x, "state": riskWorkflowStateArr[i]}        
}.bind(this));

JSFiddle: https://jsfiddle.net/urbr49d3/

Michael
  • 433
  • 4
  • 12
9

Safari for iOS does not yet support arrow functions () => {}. Use a normal function function() {} instead:

var riskWorkflowStateArr = this.riskWorkflowStateArr;
this.testArr = this.riskNamesArr.map(function(x, i) {
    return {"name": x, "state": riskWorkflowStateArr[i]}        
});

More about arrow functions.

Edit: Changed invalid this reference.

TimoStaudinger
  • 41,396
  • 16
  • 88
  • 94
  • this results in a Uncaught TypeError: Cannot read property '0' of undefined – simplesystems Jul 05 '16 at 13:05
  • @simplesystems see my edit. In normal functions, the `this` reference does not necessarily point to the `this` reference of the surrounding block. In arrow functions, it does. – TimoStaudinger Jul 05 '16 at 13:13
-3

Add this header on the server side responses to POST requests:

Cache-Control: no-cache

I suppose it's a cache problem, but not entirely sure. If it doesn't work. Please tell me and I will try to find another reason it's not working

David Gourde
  • 3,709
  • 2
  • 31
  • 65
  • This was a suggestion, a possible answer. I don't see why it should get a `-1`. The downvotes are related to the quality of the answer, not if it is the answer you were looking for or not. – David Gourde Jul 06 '16 at 15:46