contributte / forms-multiplier

:repeat: Form multiplier & replicator for Nette Framework
https://contributte.org/packages/contributte/forms-multiplier.html
MIT License
26 stars 21 forks source link

Ajaxification #15

Closed martypala closed 6 years ago

martypala commented 6 years ago

Is there some way how to ajaxify adding/removing of rows?

MartkCz commented 6 years ago

This could help

            $multiplier->addRemoveButton(null, function (SubmitButton $submitter) {
                $submitter->onClick[] = function () {
                        // redraw snippet
                };
                $submitter->setHtmlAttribute('class', 'ajax');
            });
martypala commented 6 years ago

throws MemberAccessException: Cannot read an undeclared property Nette\Forms\Controls\SubmitButton::$onSubmit.

MartkCz commented 6 years ago

Yeah sorry, I mean onClick. Edit the code

martypala commented 6 years ago

Not working, ajax css class is not appended to html element $itemsMultiplier->addRemoveButton('Smazat', function (Nette\Forms\Controls\SubmitButton $submitter) { $submitter->onClick[] = function () { $this->redrawControl('variantsCont'); }; $submitter->setHtmlAttribute('class', 'ajax'); });

MartkCz commented 6 years ago

If you use manual render you must add class into a template.

martypala commented 6 years ago

OK, now it working. Ajaxified adding/removing of rows. Thanks! Díky :)