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

It refreshes the page when add or remove container. #20

Closed matrixinfologics closed 6 years ago

matrixinfologics commented 6 years ago

It refreshes the page which takes a little while and mainly the page jumps back to the top - in case that when adding many items this might get quite anyoing. Please suggest me solution.

MartkCz commented 6 years ago

The simplest solution is snippets

$multiplier->addRemoveButton('Remove', function (Nette\Forms\Controls\SubmitButton $button) {
    $button->setHtmlAttribute('class', 'ajax');
    $button->onClick[] = function () {
        $this->redrawControl('mySnippet');
    };
});
$multiplier->addCreateButton('Create', 1, function (Submitter $button) {
    $button->setHtmlAttribute('class', 'ajax');
    $button->onClick[] = function () {
        $this->redrawControl('mySnippet');
    };
});