<html>
<head>
<meta name="description" content="QueryFixtures" />
</head>
<body>
<script type="text/x-handlebars" id="application">
profiles: {{this.content}}
<ul>
{{#each content}}
<li> hello {{this}} </li>
{{/each}}
</ul>
</script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://builds.emberjs.com/handlebars-1.0.0.js"></script>
<script src="http://builds.emberjs.com/ember-latest.js"></script>
<script src="http://builds.emberjs.com/ember-data-latest.js"></script>
</body>
</html>
window.App = Ember.Application.create({
});
App.Store = DS.Store.extend {
revision: 13
adapter: DS.FixtureAdapter.extend {
queryFixtures: (fixtures, query, type) ->
console.log fixtures.get('length') # 2
fixtures = fixtures.filter (item) ->
for prop of query
if item[prop] != query[prop]
return false
return true
console.log fixtures.get('length') # 1
return fixtures
}
}
App.ApplicationRoute = Ember.Route.extend {
init: ->
profiles = App.Profile.find { isBusiness: false }
profiles.then (data) ->
console.log 'count: ', data.get('length') # 0 ??
model: ->
return App.Profile.find({isBusiness: false })
}
App.Conversation = DS.Model.extend()
App.Profile = DS.Model.extend {
name: DS.attr('string')
businessName: DS.attr('string')
picture: DS.attr('string')
isBusiness: DS.attr('boolean')
conversations: DS.hasMany('App.Conversation')
}
App.Profile.FIXTURES = [
{
id: 1
name: 'Jon Snow'
picture: 'https://encrypted-tbn3.gstatic.com/images?q=tbn:ANd9GcRDMu58ECeoIUUSMNPCEwWv4QAp4fT1fxXNK5AxK15I6GsAiBLC5Rl50zuOGQsDOedXbfE'
isBusiness: false
conversations: [101, 102]
}
{
id: 2
name: 'Jaime Lannister'
picture: 'https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQB_K_IfaK-da-TbwgoM1NogXSc7QPVlaxaET76D8sdMoxAd1C2WCvnsKIM8-sGFpmiPPQ'
isBusiness: true
businessName: 'Westeros Inc.'
conversations: [103]
}
]
Output
300px
You can jump to the latest bin by adding /latest
to your URL
Keyboard Shortcuts
Shortcut | Action |
---|---|
ctrl + [num] | Toggle nth panel |
ctrl + 0 | Close focused panel |
ctrl + enter | Re-render output. If console visible: run JS in console |
Ctrl + l | Clear the console |
ctrl + / | Toggle comment on selected lines |
ctrl + ] | Indents selected lines |
ctrl + [ | Unindents selected lines |
tab | Code complete & Emmet expand |
ctrl + shift + L | Beautify code in active panel |
ctrl + s | Save & lock current Bin from further changes |
ctrl + shift + s | Open the share options |
ctrl + y | Archive Bin |
Complete list of JS Bin shortcuts |
JS Bin URLs
URL | Action |
---|---|
/ | Show the full rendered output. This content will update in real time as it's updated from the /edit url. |
/edit | Edit the current bin |
/watch | Follow a Code Casting session |
/embed | Create an embeddable version of the bin |
/latest | Load the very latest bin (/latest goes in place of the revision) |
/[username]/last | View the last edited bin for this user |
/[username]/last/edit | Edit the last edited bin for this user |
/[username]/last/watch | Follow the Code Casting session for the latest bin for this user |
/quiet | Remove analytics and edit button from rendered output |
.js | Load only the JavaScript for a bin |
.css | Load only the CSS for a bin |
Except for username prefixed urls, the url may start with http://jsbin.com/abc and the url fragments can be added to the url to view it differently. |