wbraganca / yii2-dynamicform

It is widget to yii2 framework to clone form elements in a nested manner, maintaining accessibility.
Other
436 stars 438 forks source link

Uncaught ReferenceError: initSelect2Loading is not defined #79

Closed vivekmarakana closed 7 years ago

vivekmarakana commented 9 years ago

I get this error when I click on the plus button.

BambangSinaga commented 9 years ago

How you solved this issue?

vivekmarakana commented 9 years ago

New version of select2 library has changed few function name and dropped few. So I just changed names and removed dropped functionality from this plugin.

tstkenny commented 9 years ago

Any chance to post your working codes please? It will help a lot of people!

klebereduardo commented 8 years ago

maybe this link could help you.. https://github.com/rburakov/yii2-dynamicform/commit/d7d596be71bbc6f7c81a457b40634630ac35eef7

marcoadasilvaa commented 8 years ago

try with this version in your composer:

        "wbraganca/yii2-dynamicform": "2.0.2",
        "kartik-v/yii2-widget-select2": "1.0.0"
vivekmarakana commented 8 years ago

You can also use my forked package for this:

"vivekmarakana/yii2-dynamicform": "dev-master",

You can find it here: https://github.com/vivekmarakana/yii2-dynamicform

ircsasw commented 8 years ago

@markmarco16 that solves the problem, thanks.

pptyasar commented 6 years ago

@marcoadasilvaa solution worked, But got another error Setting unknown property: kartik\select2\Select2::initValueText

MaGiCmAsTeR0511 commented 6 years ago

to get this error solved you have to change the yii2-dynamic-form.js in the src/asstes folder

change row 458 from $.when($('#' + id).select2(configSelect2)).done(initSelect2Loading(id, '.select2-container--krajee')); to $.when($('#' + id).select2(configSelect2)).done(initS2Loading(id, '.select2-container--krajee'));

and row 463 from initSelect2DropStyle(id, kvClose, ev); to initS2Loading(id, kvClose, ev);

BR MaGiCmAsTeR0511

mazinhorocha commented 4 years ago

A solução de @vivekmarakana funcionou muito bem para mim! Obrigado a todos

DBX12 commented 4 years ago

Monkey-patching the files in vendor/ is discouraged as it will break on a composer update. I suggest the following solution in your view file(s)

$this->registerJs('
        function initSelect2DropStyle(a,b,c){
            initS2Loading(a,b,c);
        }
        function initSelect2Loading(a,b){
            initS2Loading(a,b);
        }
    ',
    yii\web\View::POS_HEAD
);

It provides an alias to the missing functions by injecting the JS code in the head section of the generated HTML.

agafforov commented 3 years ago

@DBX12 thanks, your solution works, But, for newbies here is the full example:

` namespace components;

use yii\web\View;

class DynamicFormWidget extends \wbraganca\dynamicform\DynamicFormWidget
{
    protected function registerOptions($view)
    {
        parent::registerOptions($view);

        $view->registerJs(
            '
                function initSelect2DropStyle(a,b,c){
                    initS2Loading(a,b,c);
                }
                function initSelect2Loading(a,b){
                    initS2Loading(a,b);
                }
          ',
        View::POS_HEAD
      );
   }
}

`

maniwhereitz commented 1 year ago

to get this error solved you have to change the yii2-dynamic-form.js in the src/asstes folder

change row 458 from $.when($('#' + id).select2(configSelect2)).done(initSelect2Loading(id, '.select2-container--krajee')); to $.when($('#' + id).select2(configSelect2)).done(initS2Loading(id, '.select2-container--krajee'));

and row 463 from initSelect2DropStyle(id, kvClose, ev); to initS2Loading(id, kvClose, ev);

BR MaGiCmAsTeR0511

This worked for me. Thank you