Hi all, I'm having trouble trying to use the <addT...
# suitecommerce
g
Hi all, I'm having trouble trying to use the addToViewEventsDefinition :
Copy code
Checkout.addToViewEventsDefinition('PaymentInstrument.CreditCard.Edit.View','blur [data-action="blurCardNumber"]', function (e) {
						console.log('blurCardNumber', e)
						debugger
					});
It doesn't throw any errors, but it also doesn't work. However, if I extend the events object, it executes correctly:
Copy code
//'PaymentInstrument.CreditCard.Edit.View'
				PaymentInstrumentCreditCardEditView.prototype.events = _.extend({},
					PaymentInstrumentCreditCardEditView.prototype.events,
					{
						'blur [data-action="blurCardNumber"]': 'blurCardNumber',
					}
				)
Any idea why this might be happening??
Hi @Steve Goldberg, sorry for tagging you. Do you have any idea what could be wrong here?
s
No I don't. I would try to track down why it wasn't work such as: • Is it the blur event? What about other events? • Is it binding the handler / event listener? Check the object after your code runs • Is it binding but not firing?
g
I've checked the object and It isn't binding the event, and the same happens with the 'click' event.
s
I replicated what you did and it's definitely working as you describe it. It looks like a bug to me
🫠 1
g
It's weird that no errors are being thrown. Maybe there's something specific to this view that's causing the problem? I experimented by adding a button within the view, and it also failed to bind the event.
s
For reasons I am not privy to, the developers decided not to include errors on bad calls to the extensibility layer
g
That's okay. Can I expect this bug to be fixed in a future version of SuiteCommerce? In the meantime, I suppose I will update the core module.
s
Well you should raise a case for it and have the support team look at it. They can create an issue if they consider it a bug
I opened an issue for this after some more testing. If you do raise a case, cite issue 772268
🙌 1
t
does this affect all versions of SC/SCA?
also is it likely just an issue with that particular view? or is it an issue with addToViewEventsDefinition ?
s
I think it's an issue with addToViewEventsDefinition, as I couldn't get it to work in other areas of the application. And I don't know when it was introduced - I only tested it on SCA 23.2