简体   繁体   English

关闭一个弹出窗口并重新加载另一个弹出窗口

[英]close a pop up and reload another pop up

I am new to javascript and all so pardon me for the mistakes. 我是javascript新手,所以请原谅我的错误。 I am trying to open a pop up for some device discovery. 我正在尝试打开用于某些设备发现的弹出窗口。 When clicked on the below div, 当点击下面的div时,

<div class="ui-grid-solo">
                <div class="ui-block-a">
                    <a href="#waitDiscoveryDialog" data-rel="popup"
                    data-position-to="window" data-transition="pop"
                    class="ui-btn ui-corner-all ui-shadow ui-btn-a"
                    >Discover Device  ...</a>
                </div>
</div>

it opens a pop up like this 它会像这样打开一个弹出窗口

<div data-role="popup" id="waitDiscoveryDialog" data-overlay-theme="b" data-theme="b"
   data-dismissible="false" style="max-width:400px;">
<div data-role="header" data-theme="a">
  <h1>Device Discovery</h1>
</div>
<div role="main" class="ui-content">
  <h3 class="ui-title"
    >This will search for new Devices.</h3>

  <a href="#" class="ui-btn ui-corner-all ui-shadow ui-btn-inline ui-btn-b"
     data-rel="back">Cancel</a>
  <input type="button" data-theme="b" data-inline="true" value="Discover"
         onClick="var hi=document.createElement('input');
                  hi.type='hidden'; hi.name='action'; hi.value='Discover';
                  settings_form.appendChild(hi);
                  settings_form.submit();">
</div>
</div>

My requirement is to send the hi.name='action'; 我的要求是发送hi.name ='action'; and hi.value='Discover' without the input button in the pop up. 和hi.value ='Discover',在弹出窗口中没有输入按钮。 Because I am using flask framework and there i use this code 因为我使用的是Flask框架,所以我使用了这段代码

    if request.method == 'POST':
        rf = request.form  
        try:
            action = request.form["action"]
        except:
            action = ""
        if "Discover" == action:
         //code for discovering the device

Then close this pop up and open another pop up with a status like "Device found or not found". 然后关闭此弹出窗口,然后打开另一个状态为“找到或未找到设备”的弹出窗口。 Can anyone help me to solve this.? 谁能帮我解决这个问题。 Thanks in advance.. 提前致谢..

As I can see in your code, there is no user input in the popup and you want to submit a static value. 正如我在您的代码中看到的那样,弹出窗口中没有用户输入,您想提交一个静态值。 If this is the case, why do you even need to open a popup when it is not doing anything? 如果是这种情况,为什么您甚至在不执行任何操作时还需要打开一个弹出窗口?

You can simply write a function triggered on click of button that opens the popup as of now and submit the form. 您可以简单地编写一个单击按钮触发的函数,该函数从现在开始打开弹出窗口并提交表单。

After submission, you can continue your function to open a popup for "Device found or not found" 提交后,您可以继续您的功能以打开“找到或找不到设备”的弹出窗口
For example: 例如:

<div class="myPopup">
   <h1>This is my popup</h1>
</div>

<style>
  .myPopup {
     display: none;
     position: fixed;
     top: 0px;
     bottom: 0px;
     top: 0px;
     bottom: 0px;
     margin: auto;
     border: 1px solid black;
     border-radius: 5px;
     height: 500px;
     width: 500px; 
  }

  .showPopup {
    display: inline-block;
  }
</style>

<button title="This will search for new devices" onclick="submitForm()">Discover</button>

function submitForm() {
  var hi=document.createElement('input');
  hi.type='hidden'; hi.name='action'; hi.value='Discover';
  settings_form.appendChild(hi);
  settings_form.submit();
}

settings_form[0].addEventListener("submit", function() {
  document.getElementsByClassName("myPopup")[0].classList.add("showPopup");
});


Let me know if this helps. 让我知道是否有帮助。

请试试

<input type="button" data-theme="b" data-inline="true" onClick="var settings_form= $('formid'); settings_form.submit('Discover');">

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM