test parse role
by rowntreerob
HTML
<script src="http://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.4.1/underscore-min.js"></script>
<script src="http://cdnjs.cloudflare.com/ajax/libs/backbone.js/0.9.2/backbone-min.js"></script>
<script src="http://www.parsecdn.com/js/parse-1.2.7.min.js"></script>
<script type="text/template" id="item-template">
<li>
<div class="view">
<label class="post-content"><%= name %></label>
</div>
</li>
</script>
CSS
html, body {
margin: 0;
padding: 0;
}
button {
margin: 0;
padding: 0;
border: 0;
background: none;
font-size: 100%;
vertical-align: baseline;
font-family: inherit;
color: inherit;
-webkit-appearance: none;
-ms-appearance: none;
-o-appearance: none;
appearance: none;
}
body {
font: 14px'Helvetica Neue', Helvetica, Arial, sans-serif;
line-height: 1.4em;
background: #eeeeee url('../images/bg.png');
color: #4d4d4d;
width: 550px;
margin: 0 auto;
-webkit-font-smoothing: antialiased;
-moz-font-smoothing: antialiased;
-ms-font-smoothing: antialiased;
-o-font-smoothing: antialiased;
font-smoothing: antialiased;
}
#postapp {
background: #fff;
background: rgba(255, 255, 255, 0.9);
margin: 130px 0 40px 0;
border: 1px solid #ccc;
position: relative;
border-top-left-radius: 2px;
border-top-right-radius: 2px;
box-shadow: 0 2px 6px 0 rgba(0, 0, 0, 0.2), 0 25px 50px 0 rgba(0, 0, 0, 0.15);
}
#postapp:before {
content:'';
border-left: 1px solid #f5d6d6;
border-right: 1px solid #f5d6d6;
width: 2px;
position: absolute;
top: 45px;
top: 0px;
left: 40px;
height: 100%;
}
#postapp input::-webkit-input-placeholder {
font-style: italic;
}
#postapp input:-moz-placeholder {
font-style: italic;
color: #a9a9a9;
}
#postapp h1 {
position: absolute;
top: -120px;
width: 100%;
font-size: 70px;
font-weight: bold;
text-align: center;
color: #888;
-webkit-text-rendering: optimizeLegibility;
-moz-text-rendering: optimizeLegibility;
-ms-text-rendering: optimizeLegibility;
-o-text-rendering: optimizeLegibility;
text-rendering: optimizeLegibility;
}
.section {
position: relative;
}
#header {
padding-top: 15px;
border-radius: inherit;
}
#header:before {
content:'';
position: absolute;
top: 0;
right: 0;
left: 0;
height: 15px;
z-index: 2;
...
JavaScript
Parse.$ = jQuery;
Parse.initialize("oZCKAt268K7M3jnZIAg5XCcX72eCOJ...", "wvxtBXzkkgs1IorosCB66LMsgJHSfp6Y...");
//POST MODEL
var Post = Parse.Role.extend({});
// POST COLLECTION
var PostList = Parse.Collection.extend({
model: Post
});
// POST ITEM VIEW
var PostView = Parse.View.extend({
tagName: "li",
template: _.template($('#item-template').html()),
el: ".name",
initialize: function() {
var self = this;
_.bindAll(this);
this.Posts = new PostList();
this.Posts.query = new Parse.Query(Post);
this.Posts.fetch().then(function(){
self.render();
});
},
render: function() {
this.Posts.each(function(log) {
console.log('log item.', log);
});
}
});
var App = new PostView();