Jump to content
SebastianP

Solved: Backend: run javascript after adding new repeater item

Recommended Posts

Hi,  

is there a way to run a javascript function after add a new repeater item? I want to register an event handler on a page reference field inside the repeater item.  I have inserted a custom javascript file with a runtimemarkup field.

Thank you for any suggestions!

Regards
Sebastian

Share this post


Link to post
Share on other sites
2 hours ago, SebastianP said:

I want to register an event handler on a page reference field inside the repeater item.

Is the event handler specific to the page reference field inside only new repeater items, or should it handle events of the page reference field inside all repeater items?

Because if it's the latter you probably don't need to do anything in particular when a new repeater item is added - rather you can attach the handler to "document" and then use a selector to filter descendants. So supposing your handler is for the "change" event of selects named "foo" inside repeater items...

$(document).on('change', 'select[name^=foo_repeater]', function() {
	console.log('repeater select changed');
});

Edit: and if only inside new repeater items then this seems to do the job:

$(document).on('change', '.InputfieldRepeaterItemRequested select[name^=foo_repeater]', function() {
	console.log('new repeater item select changed');
});

 

  • Like 3

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.

×
×
  • Create New...