Basically I'm trying to create an object that manages my form. I've done this by creating a js constructor for that object and then creating a few prototypes that execute operations on that object. The issue i'm encountering is that other prototype functions are being executed when I execute the save prototype. Notice that I never actually call validate but none the less it gets called. I've put together this jsFiddle and the issue I'm seeing can be identified by putting a breakpoint in the validate function.
https://jsfiddle.net/w4xhxpo3/15/
<input type="button" id="saveBtn" value="save"/>
var stuff = {}
$(function() {
stuff = new Test(1, 'testName')
});
function Test(id, name)
{
this.id = id,
this.name = name
this.save();
}
Test.prototype.save = function(){
var _self = this;
$('#saveBtn').on('click', function() {
$.post("/echo/json/", _self)
.done(function(){
alert('success');
});
})
}
Test.prototype.validate = function(){
var _self = this;
}