kartik-v / yii2-widget-select2

Enhanced Yii2 wrapper for the Select2 jQuery plugin (sub repo split from yii2-widgets).
http://demos.krajee.com/widget-details/select2
Other
323 stars 145 forks source link

Uncaught ReferenceError: initS2Loading is not defined #294

Closed khvalov closed 4 years ago

khvalov commented 5 years ago

Have issue after composer updates. Looks like Select2 get updated to 4th branch and get this widget broken

khvalov commented 5 years ago

Looking into issue nature I've discovered that in some cases select2-krajee.js is not registered as asset: (Case: when I'm using more than 1 Select 2 widgets with different themes)

there is small workaround / quickfix (not tested for consequences)

Select2.php:

if (in_array($this->theme, self::$_inbuiltThemes)) {
            $bundleClass = __NAMESPACE__ . '\Theme' . Inflector::id2camel($this->theme) . 'Asset';
            $bundleClass::register($view);
        } 

update with:


if (in_array($this->theme, self::$_inbuiltThemes)) {
            $bundleClass = __NAMESPACE__ . '\Theme' . Inflector::id2camel($this->theme) . 'Asset';
            $bundleClass::register($view);
        }  else {
            ThemeAsset::register($view);
        }

@kartik-v please advise is it bug?

kartik-v commented 4 years ago

Not sure I can reproduce an issue here. You can check how you are loading assets on your page and if the asset bundles are loading as intended - else explicitly load the asset bundles on your view if needed. Ensure the dependencies to asset bundles are also correctly configured and loaded.

dbfernandes commented 4 years ago

This issue also happened here after composer updates. The quickfix proposed by khvalov solved the problem.

favourkiiza commented 4 years ago

Facing the same issue after composer update

kartik-v commented 4 years ago

This happens if you are using any other THEME other than inbuilt themes provided with the widget. If you are using your own theme - just create the asset bundle extending kartik\select2\ThemeAsset