如果语句在Jade / Pug中显示模态

问题描述 投票:0回答:1

我有一个像这样的Jade / PUG html文件

if post_sucess == "true"
  h1 TRUE
  script.
    $('#myModal').modal();
else if post_sucess == "false" 
  h1 FALSE

我希望myModal ID仅在if语句为true时运行。它应该是自动的,所以每当表单成功时,就会使用变量post_success呈现json页面,所以当这是真的时,我想打开#myModal

我该怎么做?

编辑:原来是语法错误,mod可以删除此帖子吗?

javascript html bootstrap-4 bootstrap-modal pug
1个回答
0
投票

请尝试此代码,也许会对您有所帮助

// This code only works with function callbacks, like click or change

$("#myModal").modal() 

// If you need to automatically show the modal, then passing some options into 
//the modal, like
$("#myModal").modal('show')
© www.soinside.com 2019 - 2024. All rights reserved.