Extending Javascript Classes

posted Jul 26, 2011, 8:43 AM by Eric Patrick
Javascript classes can be extended or overridden while maintaining prototypical inheritance.  This allows you to:
  • change or extend options, or
  • override existing methods
without a complete override of the class. If the base class is later extended within qbo.Core(Web), your class will inherit those extensions unless they conflict directly with your extensions.

Example A: Extend qbo.DebtObject to implement a custom FinancialDetailXhtml method

qbo.DebtObject.implement('FinancialDetailXhtml', function() {
new Request.HTML({
url: '/DtaWeb/DebtService.asmx/FinancialDetail',
method: 'post',
update: this.Element.id,
evalScripts: true,
debtID: this.Get('DebtID'),
xsltUrl: this.Get('XsltUrl', '/Templates/Debt/DebtFinancialDetail.xslt')
onRequest: this.Working.bind(this),
onSuccess: this.Display.bind(this),
onFailure: this.Error.bind(this)

Example B: Extend qbo.Offer to implement extended columns

qbo.OfferObject.implement('Columns', ["OfferID", "Offer", ..., "MyCustomLedgerItemA", "MyCustomLedgerItemB"]);