These are chat archives for canjs/canjs

12th
Dec 2017
Gregg Roemhildt
@roemhildtg
Dec 12 2017 21:21
Hi guys, If I have a view model that extends another view model (both define maps) and both have a submitForm on them, what's the correct way to call the parent view model class's method submitForm ?
I'm using this right now, but it seems really long: ParentVM.prototype.submitForm.call(this, arguments);
Brad Momberger
@bmomberger-bitovi
Dec 12 2017 21:24
@roemhildtg if you're using that pattern frequently you may want to try using https://canjs.com/doc/can-construct-super.html
This plugin puts a _super property on every can-construct (including DefineMap) that's set to the currently called function's parent property on the prototype chain
So from within any method on the map, you can call this._super.apply(this, arguments) and it looks a bit nicer
Gregg Roemhildt
@roemhildtg
Dec 12 2017 21:26
Ah! Nice. I do now remember that from an earlier version of canjs. Good to know it still works with define maps
Brad Momberger
@bmomberger-bitovi
Dec 12 2017 21:28
Yeah, DefineMaps are tricky because subclass instances are sealed by default, but we put some brainy people to work on solving it. :)
Gregg Roemhildt
@roemhildtg
Dec 12 2017 21:29
:) Haha quite true!