You are viewing limited content. For full access, please sign in.

Question

Question

Can not see what is wrong with my javascript, will not tell me when a collection row is deleted

asked on October 12, 2021

I have looked and looked and looked for an error in my code here. I have tried many parent classes from the collection itself to the entire form. Anyone know why this alert will not trigger when a collection row is deleted? Such I simple statement and I can't get it to trigger.

  $('.cf-formwrap').on('click','.cf-collection-delete',function(){
    alert('deleted a collection row');
  });

 

0 0

Answer

SELECTED ANSWER
replied on October 12, 2021 Show version history

Try binding to the event to the .cf-collection element, this works when I've tested it. 

TBH I'm not entirely sure why your original code doesn't work, on the surface it seems like it should work. If you find out please let me know I am curious.

$('.cf-collection').on('click','.cf-collection-delete',function(){
    alert('deleted a collection row');
  });

 

1 0
replied on October 12, 2021

This worked for me too.

However, I noticed that Chad's code works when this setting is enabled:

Very strange.

1 0
replied on October 13, 2021

Using .cf-collection works, it is the only thing that works for some reason.

Maybe the search for child objects that the second parameter of the on method uses can only reach so far down?

I can even specify my class for the collection now, as long as I also specify .cf-collection IE:

.expensesCollection .cf-collection

1 0

Replies

You are not allowed to reply in this post.
You are not allowed to follow up in this post.

Sign in to reply to this post.