I have an object called ValueBox that I created like this:
function ValueBox(params) {
...
$.extend(true, this, $('/* some HTML elements */'));
...
var $inputBox = $('input[type=text]', this);
...
this.val = function(newValue) {
if(typeof newValue == "number") {
$inputBox.val(newValue);
$inputBox.change();
} else {
return parseFloat($inputBox.val());
}
}
}
I have a change event on a particular ValueBox instance which fires whenever the $inputBox
changes, but the change callback function is unable to use the val() method in my class. I assume that by using $(this).val()
that I'm calling the jQuery val() method, which of course wouldn't work. Is it possible to access the val() method that I defined?