How to wrap an Event using an Extension in SCA

We can extend the Event function using the below code. So we can add extra events for the views without overriding the whole events

	events: _.extend(CartAddToCartButtonView.prototype.events,{
							'mouseup [data-type="add-to-cart"]': 'addToCart',
							'click [data-type="add-to-cart"]': 'addToCart'
						}),

We can also possibly extend the initialize.We are adding the example below

initialize: _.wrap(CreditCardEditFormView.prototype.initialize, function(fn) { fn.apply(this, _.toArray(arguments).slice(1)); console.log('CreditCardEditFormViewini', this.model.validation) _.extend(this.model.validation, { ccmemo: { fn: function(ccmemo) { if (!ccmemo || !jQuery.trim(ccmemo)) { return _('Nickname is required').translate(); } else if (ccmemo.length > 26) { return _('Name too long').translate(); } } } }) BackboneFormView.add(this); })

Leave a comment

Your email address will not be published. Required fields are marked *