从dash回调调用javascript函数
我一直在努力在我的dash应用程序中生成一个模态。我确实将.css和.js文件都放在了assets文件夹中,但我不确定在回调中调用.js函数的语法是什么,.js函数接受一个.css参数,然后激活它,因此它会根据更正的文件是否 .css文件,其中包含模式代码从dash回调调用javascript函数,javascript,css,plotly-dash,Javascript,Css,Plotly Dash,我一直在努力在我的dash应用程序中生成一个模态。我确实将.css和.js文件都放在了assets文件夹中,但我不确定在回调中调用.js函数的语法是什么,.js函数接受一个.css参数,然后激活它,因此它会根据更正的文件是否 .css文件,其中包含模式代码 .popup_File { position: fixed; top: 50%; left: 50%; transform: translate(-50%, 50%) scale(0); transition: 500ms
.popup_File {
position: fixed;
top: 50%;
left: 50%;
transform: translate(-50%, 50%) scale(0);
transition: 500ms ease-in-out;
border: 1px solid black;
border-radius: 10px;
z-index: 10px;
width: 500px;
max-width: 80%;
}
.popup_File.active{
transform: translate(-50%, 50%) scale(1);
}
.js编码用于在css文件中激活模式的Javascript函数
function openmodal(popup){
if (popup == null) return
popup.classList.add('active')
document.write('see')
}
我希望实际激活css模式的回调(请参见注释)->
我一直在努力寻找要使用的正确语法,以及如何放置.js代码,并使用Python dash中的正确参数调用assets文件夹中的函数。请帮忙为什么所有的空白行!!!请尝试使代码可读性我是新手,但会的。我确实尝试使它更可读一点。现在清楚了吗?您可能需要修复python格式。。。我从来都不知道如何格式化pythonI刚刚提交的文件,我已经为这个看起来很简单的问题奋斗了太久。我确实添加了剩余的代码以使其更具可读性。我真的很欣赏这种格式。
import dash_bootstrap_components as dbc
import dash_bootstrap_components as dbc
import dash_core_components as dcc
import dash_html_components as html
from dash.dependencies import Input, Output, State, ClientsideFunction
app = dash.Dash(__name__, external_stylesheets=[dbc.themes.JOURNAL])
app.layout = html.Div(
className = 'popup_File',
id = 'Wrong_file',
children = [
html.Div(
className = 'header',
children = [
html.Div("Invalid file type", className = 'title'),
html.Button('×', className = 'Close_wrongFile', id = 'File')]),
html.Div('The file you have uploaded does not have the vcf file extension.', className = 'Warning_wrongfile')
]
)
#Call back for checking uploaded file
@app.callback(
Output('place_Filename', 'children'),
[Input('VCF', 'contents')],
[State('VCF', 'filename')]
)
def VCF_processing(contents, filename):
if filename is None:
layout = html.Div(
[
html.H6(
'Drag and Drop .vcf '
)
]
)
return layout
else:
if '.vcf' not in filename:
#... I want to call the .js function here to tell the user that an incorrect file has been uploaded
return warning modal
if __name__ == '__main__':
app.run_server(debug=False)