Tuesday, September 21, 2010

Variable Scope: cross-class function call

Programmer Question

I have a vehicle and a product object and I need vehicle to call a function within product.... I can't seem to figure it out, what should I do here?



var vehicle = function () {
return {
init: function () {
var that = this;

jQuery('.vehicle-year-profile .options .delete').bind('click', function (e) {
e.preventDefault();
that.remove(jQuery(e.currentTarget).parents('.vehicle-year-profile'));
});

jQuery('.vehicle-year-profile .options .edit').bind('click', function (e) {
e.preventDefault();
that.edit(jQuery(e.currentTarget).parents('.vehicle-year-profile').attr('id'));
});

jQuery('#association-detail .save').bind('click', function (e) {
e.preventDefault();
that.save();
});
},
edit: function (id) {},
save: function () {},
remove: function (el) {},
reset: function () {}
}
}();

var product = function () {
return {
refreshHistory: function () {}
};
}();


Find the answer here

No comments:

Post a Comment

LinkWithin

Related Posts with Thumbnails