I have 3 functions on an object prototype:
Job.prototype.postData = function(url) {
this.getFormData();
var formdata = new FormData();
formdata.append("position", this.position);
formdata.append("team", this.team);
formdata.append("details", this.details);
$.post(url, formdata, function(response) {
alert(response.message);
window.location.href = '/';
});
};
Job.prototype.createNew = function() {
var newUrl = API_URL + "/add_listing";
this.postData(newUrl)
};
Job.prototype.update = function() {
var updateUrl = API_URL + "/edit_listing" + "?id=" + this.id;
this.postData(updateUrl)
};
I'm attaching the last two as event handling callbacks:
$('#list-button').on('click',job.createNew);
$('#list-button').on('click',job.update);
Both of those give a TypeError
:
oop.js:38 Uncaught TypeError: this.postData is not a function