yiisoft / yii2

Yii 2: The Fast, Secure and Professional PHP Framework
http://www.yiiframework.com
BSD 3-Clause "New" or "Revised" License
14.23k stars 6.91k forks source link

Uncaught ReferenceError: bootstrapSwitch_9a42af04 is not defined #18814

Closed strtob closed 3 years ago

strtob commented 3 years ago

Hi guys,

I use yii2 and open a modal window to load a form. It works many times without problems, but now, I get the following message in my firefox console:

Uncaught ReferenceError: bootstrapSwitch_9a42af04 is not defined
    <anonymous> fp-profile line 133 > injectedScript:324
    jQuery 14
    <anonymous> modal.js:77
    jQuery 8
    <anonymous> alert.js:154
    <anonymous> bootstrap.bundle.js:9
    <anonymous> bootstrap.bundle.js:10

the error pointed to:

if (jQuery('#fpprofile-isactive').data('bootstrapSwitch')) { jQuery('#fpprofile-isactive').bootstrapSwitch('destroy'); }
jQuery("#fpprofile-isactive").bootstrapSwitch(bootstrapSwitch_9a42af04);

If I delete the switch, the problem occurs with the next UI, e.g. input text field. I've deleted the asset and vendor dir, set force copy to true, no success. For me it seems, yii pointed to a wrong (old) asset?

Additional info

Q A
Yii version 2.0.43-dev?
PHP version 7.4.16
Operating system Linux
samdark commented 3 years ago

What's bootstrapSwitch?

strtob commented 3 years ago

Hi Sam,

Thanks for your quick response! This is a SwitchInput by Kartik.

I use CKEditor by 2amigos.

From today, the same here:

Uncaught ReferenceError: inputmask_b02ee1d6 is not defined
    <anonymous> fp-profile line 133 > injectedScript:1
    jQuery 14
    <anonymous> modal.js:77
    jQuery 8
    <anonymous> alert.js:154
    <anonymous> bootstrap.bundle.js:9
    <anonymous> bootstrap.bundle.js:10

source from firefox debug tools points to the first row of this:

jQuery("#tokenmessage-emailto").inputmask(inputmask_b02ee1d6);
jQuery("#tokenmessage-emailcc").inputmask(inputmask_b02ee1d6);
CKEDITOR.replace('tokenmessage-message', {"height":200,"toolbarGroups":[{"name":"clipboard","groups":["mode","undo","selection","clipboard","doctools"]},{"name":"editing","groups":["tools","about"]},"/",{"name":"paragraph","groups":["templates","list","indent","align"]},{"name":"insert"},"/",{"name":"basicstyles","groups":["basicstyles","cleanup"]},{"name":"colors"},{"name":"links"},{"name":"others"}],"removeButtons":"Smiley,Iframe"});
dosamigos.ckEditorWidget.registerOnChangeHandler('tokenmessage-message');

If you delete the widget form the source code, save, refresh the window - put it in the source code again and save - it works. What happens here? :-/

bizley commented 3 years ago

This looks like something caused by one of these widgets. Why do you think it's Yii's issue?

strtob commented 3 years ago

Due to the fact that widgets made by different developers are affected, may it be caused in the field of assets management?

samdark commented 3 years ago

Looks like the issue isn't stable to reproduce. More than that, we have no way to reproduce it at our side. Also, it's not clear what it might be connected with.

Thus, we can not do anything about it. If you'll get more data on it leading to a clear way to reproduce it on a clean framework (basic app), please post it.

dmitry-kulikov commented 2 years ago

It is not a bug in Yii and not a bug at all. I had the same problem with SwitchInput by Kartik. The solution is to use

'hashVarLoadPosition' => View::POS_READY,

for SwitchInput widget settings. Maybe it will help to someone.