Skip to content

Instantly share code, notes, and snippets.

@chrism
Created February 10, 2014 11:08
Show Gist options
  • Save chrism/8914065 to your computer and use it in GitHub Desktop.
Save chrism/8914065 to your computer and use it in GitHub Desktop.
<!DOCTYPE html>
<html>
<head>
<meta name="description" content="Ember mapBy Example" />
<meta charset="utf-8">
<title>Ember mapBy Example</title>
<link rel="stylesheet" href="http://cdnjs.cloudflare.com/ajax/libs/normalize/2.1.0/normalize.css">
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
<script src="http://builds.handlebarsjs.com.s3.amazonaws.com/handlebars-v1.3.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script src="http://builds.emberjs.com/ember-data-latest.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/jquery-mockjax/1.5.3/jquery.mockjax.min.js"></script>
</head>
<body>
<script type="text/x-handlebars" data-template-name="application">
<p>{{value}}</p>
<p>{{returnMap}}</p>
</script>
</body>
</html>
App = Ember.Application.create({});
App.ApplicationController = Ember.Controller.extend({
value: "returns array in uuid format",
returnMap: function() {
var originalArray = [
{
"image": {
"uuid": "8dc22a0a-06f9-45fa-812c-c0fe66628c44",
"state": "complete",
"source": "url",
"source_url": "http://alltheyoungpunks09.files.wordpress.com/2011/11/thee-oh-sees-kelly-o-1.jpg"
}
},
{
"image": {
"uuid": "3eaebaaa-b05e-429a-be8f-45851e030c40",
"state": "complete",
"source": "url",
"source_url": "http://alltheyoungpunks09.files.wordpress.com/2011/11/thee-oh-sees-kelly-o-1.jpg"
}
}
]
var newArray = originalArray.mapBy('image.uuid','uuid');
return JSON.stringify(newArray);
}.property()
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment