Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Symfony collection added dynamically doesn't work #132

Open
Jerome1337 opened this issue Jun 5, 2018 · 3 comments
Open

Symfony collection added dynamically doesn't work #132

Jerome1337 opened this issue Jun 5, 2018 · 3 comments

Comments

@Jerome1337
Copy link

Jerome1337 commented Jun 5, 2018

When we add a symfony collection form dynamically with JavaScript, the buttons (add, remove, ...) are not working anymore.

To made it work I used .arrive event to initialize the collection when it's added dynamically.

$(document).arrive('select', (element) => {
   if ($element.length) {
      /* eslint-disable */
      $element.collection({
        add: '<button type="button" class="add"><i class="fa fa-plus"></i></button>',
        allow_duplicate: false,
        allow_down: false,
        allow_up: false,
        remove: '<button type="button" class="remove"><i class="fa fa-minus"></i></button>',
        max: 500,
      });
      /* eslint-enable */
    }
});

Is this will be fixed in next update, or did I need to prepare a pull request to fix this ?

@ninsuo
Copy link
Owner

ninsuo commented Jun 5, 2018

Hi @Jerome1337

I don't think .arrive is native jQuery, and thus this won't be easily fixed.

Let me leave this issue open to look for a solution once I'll have the time to tackle it.

Have a great night,
Alain

@Jerome1337
Copy link
Author

Jerome1337 commented Jun 6, 2018

Hi,

I don't think .arrive is native jQuery, and thus this won't be easily fixed.

.arrive is not native and from https://github.com/uzairfarooq/arrive

Let me leave this issue open to look for a solution once I'll have the time to tackle it.

No problem.

Regards.

@dachinat
Copy link

dachinat commented Aug 11, 2018

Hi. I'm facing similar issue. I load form html using $.get and initiate this plugin afterwards. Buttons are rendered and I can "sometimes" use delete button, but other buttons don't work.

What do you recommend here, when form is being loaded through ajax? Thanks.

Sorry. I solved it by resolving some conflicts that where in my project.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants