emilhe / dash-leaflet

MIT License
213 stars 37 forks source link

Error: No match for [dashExtensions.default.function0] in the global window object. #243

Closed yann-h closed 2 months ago

yann-h commented 3 months ago

Hi,

I tried to used the example described at : https://www.dash-leaflet.com/docs/events

The example were not working because of this error showing in the JavaScript console :

Error: No match for [dashExtensions.default.function0] in the global window object.

I found that i needed to add an assets/some.js file alongside my app.py file with this content :

window.dashExtensions = Object.assign({}, window.dashExtensions, {
    default: {
        function0: function(e, ctx) {
            console.log(`You clicked at ${e.latlng}.`)
        }
    }
});

I found this function in the test/assets/dashExtensions_default.js file of the dash-extensions project.

Is this some kind of error ? Or should it only need to be documented in dash-leaflet ?

emilhe commented 3 months ago

That file was supposed to be auto generated. What environment are you using?

yann-h commented 3 months ago

Python 3.11.7 pipenv, version 2023.11.17 Mac OS Sonoma 14.1

dash==2.17.1; python_version >= '3.8' dash-auth==2.3.0; python_version >= '3.8' dash-core-components==2.0.0 dash-extensions==1.0.17; python_version >= '3.9' and python_version < '4' dash-html-components==2.0.0 dash-leaflet==1.0.15 dash-table==5.0.0

yann-h commented 3 months ago

The file is indeed generated but the assets directory is generated in the directory where i'm executing the script, not alongside the app.py file.

I'm lauching : python src/app.py

Changing the assets_folder to the current execution directory resolves the problem : app = Dash(__name__, assets_folder=f"{os.getcwd()}/assets")

muhammedsural commented 2 months ago

Problem is python environment. When ı working on python 3.12, dash app error but switch the python 3.11.3 environment errors solved.

emilhe commented 2 months ago

Seems that this is solved. Otherwise, please re-open.