Created
February 25, 2013 12:10
-
-
Save akbsteam/5029409 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$(function() { | |
Parse.$ = jQuery; | |
// Initialize Parse with your Parse application javascript keys | |
Parse.initialize("APP-KEY", | |
"JAVASCRIPT-ID"); | |
// The main view for the app | |
var AppView = Parse.View.extend({ | |
el: $("#contact"), | |
events: { | |
"submit form.contact-form": "contact", | |
}, | |
initialize: function() { | |
_.bindAll(this, "contact"); | |
this.render(); | |
}, | |
contact: function(e) { | |
var self = this; | |
var data = { | |
name: this.$("#contact-name").val(), | |
email: this.$("#contact-email").val(), | |
phone: this.$("#contact-phone").val() | |
}; | |
Parse.Cloud.run("hello", data, { | |
success: function(object) { | |
$('#contact').html("Thanks for your email!"); | |
delete self; | |
}, | |
error: function(object, error) { | |
console.log(error); | |
this.$(".contact-form button").removeAttr("disabled"); | |
} | |
}); | |
this.$(".contact-form button").attr("disabled", "disabled"); | |
return false; | |
}, | |
render: function() { | |
this.$el.html(_.template($("#contact-template").html())); | |
this.delegateEvents(); | |
} | |
}); | |
new AppView; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html> | |
<head> | |
<meta charset="utf-8"> | |
<title>Testing</title> | |
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script> | |
<script src="js/underscore-1.1.6.js"></script> | |
<script src="//www.parsecdn.com/js/parse-1.1.15.min.js"></script> | |
<script src="js/contact.js"></script> | |
</head> | |
<body> | |
<div id="contact"> | |
</div> | |
<!-- Templates --> | |
<script type="text/template" id="contact-template"> | |
<header id="header"></header> | |
<div class="contact"> | |
<form class="contact-form"> | |
<h2>Contact us</h2> | |
<div class="error" style="display:none"></div> | |
<input type="text" id="contact-name" placeholder="Name" /> | |
<input type="text" id="contact-email" placeholder="Email" /> | |
<input type="text" id="contact-phone" placeholder="Phone number" /> | |
<button>Send</button> | |
</form> | |
</div> | |
</script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This code don`t work...