JSFiddle - React, Tailwind, and code Playground
by Wesley Smith
HTML
<script src="http://www.parsecdn.com/js/parse-1.3.3.min.js"></script>
<input type="button" value="Red" class="vote"/>
<input type="button" value="Green" class="vote"/>
<input type="button" value="Blue" class="vote"/><br><br>
<div id="link"></div>
JavaScript
Parse.initialize("XAGsq7BnHObLRDpIS7M62S2BpuXnLbg8QX07LWVI", "potSd8VBTt1Y5Bk8NVe5OUUmcC69jYU4wDGo7NHQ");
$('.vote').click(function(){
// create the `Parse` object
var ColorVote = Parse.Object.extend("ColorVote");
var _colorVote = new ColorVote();
// set the object's value to our button value
_colorVote.set("color", $(this).val());
// save the object
_colorVote.save(null, {
success: function(_colorVote) {
// if the save succeeded, give link to view results
$('#link').html('Vote saved! Please <a href="http://jsfiddle.net/DelightedDoD/ekgj2y5L/2/" target="_blank">click here</a> here to see the results of the vote so far.')
},
error: function(_colorVote, error) {
// save failed, do error handeling here
console.log('Failed to create new object, with error code: ' + error.message);
}
});
});