my set params is null for some reason. But the variables i'm passing in do have values. I have a console.log before I set params to check before the parameters are set to their values.
Can anyone spot something wrong in my code?`
onDrop: function(component, event, helper)
{
event.preventDefault();
var index = component.get('v.index');
var seatNumber = component.get('v.seatNumber');
console.log("Target Item Index:",index,"\nTarget Item Seat:",seatNumber); //These work, and have values.
var cardSwapEvent = component.getEvent('CardOnCardSwap');
cardSwapEvent.setParams({'seatNumber': seatNumber, index: index}); //This complains "Cannot read property 'setParams' of null"
cardSwapEvent.fire();
console.log("CardonCard");
}`
Console output:
Moved Item index: 0 Moved Item Seat: 1 Card.js:26 Target Item Index: 1 Target Item Seat: 2
Error message:
This page has an error. You might just need to refresh it. Action failed: c:Card$controller$onDrop [Cannot read property 'setParams' of null] Failing descriptor: {c:Card$controller$onDrop}
name
attribute while registering and handling a component event should be exactly the same. Seems you declared the eventname
in your registering component ascardSwapRegister
and then in handler you have it ascardSwapped
, that will not work. Also can you please add the snippet from the comments to your question, that will help to get the full context here.